in reply to Re^4: Protection from zombies
in thread Protection from zombies
This seems to be bulletproof. How can I get that using Perl?#include <sys/types.h> #include <sys/wait.h> #include <unistd.h> static char buf[512]; int main() { int pfd[2]; pipe( pfd ); pid_t pid = fork(); if ( pid ) { /* parent */ close( pfd[1] ); ssize_t s = read( pfd[0], buf, sizeof(buf) ); waitpid( pid, NULL, 0 ); } else { /* child */ close( pfd[0] ); dup2( pfd[1], STDOUT_FILENO ); close( STDOUT_FILENO ); } return 0; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Protection from zombies
by kscaldef (Pilgrim) on May 17, 2005 at 17:51 UTC |