Messages in this thread | | | Date | Fri, 21 May 1999 22:50:10 +0100 | From | Jonathan Larmour <> | Subject | Possible task exit bug? |
| |
Have a look at the following trivial program:
-=-=-=-=-=-=-=-=-=-=- #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <errno.h>
int main() { pid_t pid;
pid = fork();
// child if (pid==0) { exit(0); } else { // parent sleep(2); if (waitpid(pid, (int *)0, 0) == -1) { printf("error: %s\n", strerror(errno)); } } return 0; } -=-=-=-=-=-=-=-=-=-=-
If I run this directly from the shell, its fine - there's no output. If I run it from a cron or "at" job on Linux I get "error: No child processes" i.e. ECHILD. This works on Solaris but fails on both linux 2.0.36/glibc2.0 and linux 2.2.2/glibc2.1. But its not clear to me why it succeeds on a tty, but not from cron. I get the same effect on a tty if I put an explicit "signal(SIGCHLD, SIG_IGN);" near the top.
An strace shows that the SIGCHLD is getting sent, but analysis with ps shows that in the case where it is run from a tty, the zombie stays around; but when run from cron, the child just disappears immediately.
They should be in the same process group, so that can't be the problem. I had a look at kernel/exit.c, but couldn't work out the purpose of oppid (among other things), so I decided it was easier to ask here :-). glibc fork and waitpid just go straight through to the kernel, so if there is a problem (which I believe there is), it seems its in the kernel.
So, any thoughts?
Jifl -- Cygnus Solutions, 35 Cambridge Place, Cambridge, UK. Tel: +44 (1223) 728762 "I used to have an open mind but || Get yer free open source RTOS's here... my brains kept falling out." || http://sourceware.cygnus.com/ecos Help fight spam! http://spam.abuse.net/ These opinions are all my own fault
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |