Saturday, December 12, 2015

Find the process name using the process id

ps -p 1 -o comm=

/sbin/launchd

-p : PID
-o : command name

In this case the process id is 1 and comm is the command name. The story behind why I had to use this command. MySQL server stopped working on my Mac. It was complaining that the server process had quit without updating the PID file. The PID file did not exist. So I created one and put process id 1 as the value. When I made an attempt to restart the MySQL server, the entire machine rebooted. It turns out that the process with id one is the launchd that starts all other child processes in Mac.