
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] Apache running as root?
>>>>> "TM" == Tod McQuillin <devin@example.com> writes:
    TM> No.  The parent can exit without killing its children.
... because they are inherited by init which will then wait for them
as every normal UNIX parent would.
    TM> #include <unistd.h>
    TM> #include <stdio.h>
    TM> int main()
    TM> {
    TM>   int i;
    TM>   switch (fork()) {
    TM>   case 0:			/* child */
    TM>     for (i = 1; i <= 5; ++i) {
    TM>       sleep(1);
    TM>       printf("child alive for %d seconds\n", i);
printf("child alive for %d seconds, parent pid = %d\n", i, getppid());
    TM>     }
    TM>     return 0;
    TM>   case -1:			/* error */
    TM>     perror("fork");
    TM>     return 1;
    TM>   default:			/* parent */
    TM>     printf("parent exiting\n");
    TM>     return 0;
    TM>   }
    TM> }
regards
Viktor
Home |
Main Index |
Thread Index