home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ukma!darwin.sura.net!mips!decwrl!bu.edu!cs!tasos
- From: tasos@cs.bu.edu (Anastasios Kotsikonas)
- Newsgroups: comp.unix.aix
- Subject: system() and SIGCHLD
- Message-ID: <94029@bu.edu>
- Date: 19 Aug 92 14:13:42 GMT
- Sender: news@bu.edu
- Organization: Computer Science Department, Boston University, Boston, MA, USA
- Lines: 63
- Originator: tasos@cs
-
- A few weeks ago I posted the following question to comp.unix.programmer:
-
- If process A forks B, then A does a system(), is A supposed to receive
- a SIGCLD when system() returns?
-
- All replies said no, and some people were astonished that AIX had this
- "problem" [really!]. Well, this time I have included the program below
- to show that it does indeed happen, on a number of hosts actually.
-
- If any can suggest a workaround I would really appreciate it.
-
- Tasos
-
- ------------------------------ systest.c ----------------------------
- #include <stdio.h>
- #include <signal.h>
-
- int pid;
-
- main ()
- {
- extern int sighandle();
-
- #ifdef SIGCLD
- signal (SIGCLD, (void *) sighandle);
- #else
- signal (SIGCHLD, (void *) sighandle);
- #endif
- if ((pid = fork ()) < 0)
- perror ("Cannot fork"),
- exit (1);
- else if (pid == 0)
- while (1);
- else
- system ("/bin/echo > /dev/null");
- sleep (2);
- printf ("system() OK.\n");
- #ifdef SIGCLD
- signal (SIGCLD, SIG_DFL);
- #else
- signal (SIGCHLD, SIG_DFL);
- #endif
- kill (pid, SIGKILL);
- exit (0);
- }
-
- sighandle (sig)
- int sig;
- {
- fprintf (stderr, "system() bug.\n");
- #ifdef SIGCLD
- signal (SIGCLD, SIG_DFL);
- #else
- signal (SIGCHLD, SIG_DFL);
- #endif
- kill (pid, SIGKILL);
- exit (2);
- }
- --
- --
- Tasos Kotsikonas | tasos@cs.bu.edu | Work : Advanced Visual Systems
- Ex BU Country | | email: tasos@avs.com
- Club Member. | | Duties: none
-