:: MArX'' Frustrated communist, card-carrying geek.

22Jun/100

Get application pid listening on a network port on Solaris

This week, a coworker asked my opinion about a problem. He needed to startup a service, but the port which this service needed to bind was already in use.

The problem seemed simple, figure out which process was binded on this port, check if it was an stuck instance of the same service previously ran or a legitimate service and then take appropriate action.

Usually the netstat command has a parameter to inform the process associated to the port, it's -p on Linux, -b on windows and so on. But, what about Solaris? Damn! Solaris's netstat hasn't this feature.

I found away various ideas to solve the problem, but all they using one of two approaches, lsof or pfiles. The lsof isn't built-in on Solaris, so only left me pfiles.

Filed under: Solaris Continue reading