[PATCH] new -D option: move strace process into background. Preserves parent<->child link

Denys Vlasenko dvlasenk at redhat.com
Fri Sep 26 13:34:08 UTC 2008


On Fri, 2008-09-26 at 15:24 +0200, Denys Vlasenko wrote:
> Example programs:
> 
> timeout1.c

Correction: need to set SIGCHLD to SIG_IGN, otherwise
presence of unwaited-for zombies produces bogus
"Process is still alive!" warning.

#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
int main(int argc, char **argv)
{
        int pid;
        signal(SIGCHLD, SIG_IGN); /* please no zombies */
        pid = fork();
        if (!pid) {
                execvp(argv[1], argv + 1);
                return 1;
        }
        sleep(1);
        kill(pid, SIGUSR1) || puts("Sent SIGUSR1");
        usleep(150*1000);
        kill(pid, SIGTERM) || puts("Sent SIGTERM");
        usleep(150*1000);
        kill(pid, 0) || puts("Process is still alive!");
        return 0;
}

--
vda





More information about the Strace-devel mailing list