Get Apache process's pid from php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sentino
Forum Newbie
Posts: 5
Joined: Thu Nov 27, 2008 9:08 pm

Get Apache process's pid from php

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Get Apache process's pid from php

Post by John Cartwright »

I'm not sure about the mysql user, however to acquire the pid you can simply use getmypid()
sentino
Forum Newbie
Posts: 5
Joined: Thu Nov 27, 2008 9:08 pm

Re: Get Apache process's pid from php

Post by sentino »

I believe that getmypid() returns the process id of the php running script itself and not Apache processes' id.
Am I right?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: Get Apache process's pid from php

Post by Mark Baker »

posix_getppid() will return the apache parent process
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: Get Apache process's pid from php

Post by John Cartwright »

Thanks for the correction, Mark.
Post Reply