How can I close a port that appears to be orphaned by Xvfb?
- by Jim Fiorato
I'm running Xvfb on a FC8 Amazon EC2 image. On occasion Xvfb will crash (unable at the moment to find out the reason for the crash), and after crashing the TCP port will appear to be orphaned. I'm unable to get a PID to kill any process that may be using it.
I'm starting Xvfb with:
Xvfb :7 -screen 0 1024x768x24 &
Examples of what I'm working with are below, the Xvfb port is (was) 6007:
# netstat -ap
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:ssh *:* LISTEN 1894/sshd
tcp 0 0 *:6007 *:* LISTEN -
tcp 0 352 ip-10-84-69-165.ec2.int:ssh c-71-194-253-238.hsd1:51689 ESTABLISHED 2981/0
udp 0 0 *:bootpc *:* 1817/dhclient
udp 0 0 *:bootpc *:* 1463/dhclient
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ] DGRAM 871 668/udevd @/org/kernel/udev/udevd
unix 2 [ ACC ] STREAM LISTENING 5385 1880/dbus-daemon /var/run/dbus/system_bus_socket
unix 6 [ ] DGRAM 5353 1867/rsyslogd /dev/log
unix 2 [ ] DGRAM 11861 2981/0
unix 2 [ ] DGRAM 5461 1974/crond
unix 2 [ ] DGRAM 5451 1904/console-kit-da
unix 3 [ ] STREAM CONNECTED 5438 1880/dbus-daemon /var/run/dbus/system_bus_socket
unix 3 [ ] STREAM CONNECTED 5437 1904/console-kit-da
unix 3 [ ] STREAM CONNECTED 5396 1880/dbus-daemon
unix 3 [ ] STREAM CONNECTED 5395 1880/dbus-daemon
unix 2 [ ] DGRAM 5361 1871/rklogd
# lsof -i
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
dhclient 1463 root 3u IPv4 4704 UDP *:bootpc
dhclient 1817 root 4u IPv4 5173 UDP *:bootpc
sshd 1894 root 3u IPv4 5414 TCP *:ssh (LISTEN)
sshd 2981 root 3u IPv4 11825 TCP ip-10-84-69-165.ec2.internal:ssh->c-71-194-253-238.hsd1.il.comcast.net:51689 (ESTABLISHED)
Attempting to force the port closed with iptables doesn't seem to work either.
iptables -A INPUT -p tcp --dport 6007 -j DROP
I'm at a loss as to how to reclaim/free the port. From what I can tell, this port will remain in this state until the EC2 instance is shut down.
So, how can I close this port so I can restart Xvfb?