Page 1 of 1

Get Apache process's pid from php

Posted: Thu Nov 27, 2008 9:15 pm
by sentino
Hello, I have phpmyadmin application where clients can use it to access Mysql. I have Apache2 web server (prefork module) installed on Linux machine. For each HTTP request from the clients, Apache assigns a child process to serve this request. I can see the PID of the processes in server-status file (http://localhost/server-status.html) but I would like to know how can I obtain the Apache process's id of each request as well as the user id (Mysql user) from php. (I mean how to write a php script to log the Mysql user and the PID of each request).
Thank you

Re: Get Apache process's pid from php

Posted: Thu Nov 27, 2008 10:01 pm
by John Cartwright
I'm not sure about the mysql user, however to acquire the pid you can simply use getmypid()

Re: Get Apache process's pid from php

Posted: Fri Nov 28, 2008 8:17 am
by sentino
I believe that getmypid() returns the process id of the php running script itself and not Apache processes' id.
Am I right?

Re: Get Apache process's pid from php

Posted: Fri Nov 28, 2008 8:25 am
by Mark Baker
posix_getppid() will return the apache parent process

Re: Get Apache process's pid from php

Posted: Fri Nov 28, 2008 11:19 am
by John Cartwright
Thanks for the correction, Mark.