Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Apache running as root?



On Tue, 28 May 2002, Christopher SEKIYA wrote:

> > However I still have the one process running as root.
>
> ... because the parent process, once forked, cannot exit without killing
> its children.

No.  The parent can exit without killing its children.  For example:

#include <unistd.h>
#include <stdio.h>

int main()
{
  int i;

  switch (fork()) {
  case 0:			/* child */
    for (i = 1; i <= 5; ++i) {
      sleep(1);
      printf("child alive for %d seconds\n", i);
    }
    return 0;
  case -1:			/* error */
    perror("fork");
    return 1;
  default:			/* parent */
    printf("parent exiting\n");
    return 0;
  }
}

The reason the root process stays around is to accomodate the
'MaxRequestsPerChild' httpd.conf option, which causes the child processes
to exit after a certain number of requests (as a workaround for memory
leaks on some OS's).  When a child exits, the parent process restarts it.
(There may be other reasons for the root-owned httpd also; this was just
the first that came to mind.)

Anyway, the root-owned httpd is normal, and does not actually service any
incoming http requests.
-- 
Tod McQuillin



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links