Apache and os.fork() in CGI-Binaries

Erno Kuusela erno-news at erno.iki.fi
Fri Mar 9 09:02:08 CET 2001

In article <3AA84BF3.E19873DB at ninenet.com>, Matt Harden
<matth at ninenet.com> writes:

| Simon,
| You need os.dup2().  Like this:
|    logfile = os.open("/path/to/logfile",os.O_CREAT|os.O_WRONLY)
|    os.lseek(logfile, 0, 2)  /* seek to end */
|    os.dup2(logfile, sys.stdout.fileno())
|    os.dup2(logfile, sys.stderr.fileno())
|    os.close(logfile)

it is better to use O_APPEND with log files. you may also need
to lock it so that many processes do not write to it at the same time.

  -- erno

More information about the Python-list mailing list