From: Albert Cahalan <albert@users.sf.net>
To: linux-kernel mailing list <linux-kernel@vger.kernel.org>
Subject: unkillable process
Date: 14 Oct 2004 01:20:27 -0400 [thread overview]
Message-ID: <1097731227.2666.11264.camel@cube> (raw)
It's really bad when a task group leader exits.
The process becomes unkillable.
This is with the 2.6.8-rc1 kernel. I haven't seen
any mention of this getting fixed since then.
Here's the top of the /proc/*/status file:
Name: a.out
State: Z (zombie)
SleepAVG: 59%
Tgid: 9662
Pid: 9662
PPid: 1
TracerPid: 0
Uid: 1000 1000 1000 1000
Gid: 1000 1000 1000 1000
FDSize: 0
Groups: 500 1000
Threads: 9
Here's the code:
///////////////////////////////////////////////////////////////
#include <sys/types.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <sched.h>
#ifndef CLONE_THREAD
#define CLONE_THREAD 0x00010000
#endif
#ifndef CLONE_DETACHED
#define CLONE_DETACHED 0x00400000
#endif
#ifndef CLONE_STOPPED
#define CLONE_STOPPED 0x02000000
#endif
#define FLAGS (CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_VM|CLONE_THREAD|CLONE_DETACHED)
static pid_t one;
static void die(int signo){
(void)signo;
_exit(0);
}
static void hang(void){
for(;;) pause();
}
static int clone_fn(void *vp){
(void)vp;
hang();
return 0; // keep gcc happy
}
static long clone_stack_data[2048];
#ifdef __hppa__
static long *clone_stack = &clone_stack_data[0];
#else
static long *clone_stack = &clone_stack_data[2048];
#endif
int main(int argc, char *argv[]){
pid_t minime;
int i = 8;
(void)argc;
(void)argv;
one = getpid();
signal(SIGHUP,die);
if(fork()) hang(); // parent later killed as readyness signal
while(i--){
// better be stopped... they share a stack
minime = clone(clone_fn, clone_stack, FLAGS | CLONE_STOPPED, NULL);
if(minime==-1){
perror("no clone");
kill(one,SIGKILL);
_exit(8);
}
}
kill(one,SIGHUP); // let the shell know we're ready
_exit(0); // make task group leader a zombie
return 0; // keep gcc happy
}
/////////////////////////////////////////////////////////////////////
next reply other threads:[~2004-10-14 5:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-14 5:20 Albert Cahalan [this message]
2004-10-14 7:40 ` unkillable process Andrew Morton
2004-10-14 12:26 ` Johan Kullstam
2004-10-14 15:12 ` Alex Riesen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1097731227.2666.11264.camel@cube \
--to=albert@users.sf.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.