Can I just delete a stale file handle?

Using applications, configuring, problems
Post Reply
Message
Author
s243a
Posts: 2580
Joined: Tue 02 Sep 2014, 04:48
Contact:

Can I just delete a stale file handle?

#1 Post by s243a »

If I accidently start freenet as the wrong user, kill the process and try to re-start it as the correct user, it won't bind to the fproxy port due to a stale file handle.

In my example I set the fproxy port to 8889

For diagnostic purposes I deleted the busybox version of lsof and installed lsof from the package manager.

I can then type:

Code: Select all

# /usr/bin/lsof -i :8889
COMMAND     PID USER   FD   TYPE  DEVICE SIZE/OFF NODE NAME
java       1443 spot   20u  IPv4 9957491      0t0  TCP localhost:8889 (LISTEN)
java       1443 spot   23u  IPv4 9962045      0t0  TCP localhost:8889->localhost:48948 (CLOSE_WAIT)
java       1443 spot   24u  IPv4 9963979      0t0  TCP localhost:8889->localhost:48949 (CLOSE_WAIT)
java       1443 spot   25u  IPv4 9965114      0t0  TCP localhost:8889->localhost:48952 (CLOSE_WAIT)
java       1443 spot   26u  IPv4 9968846      0t0  TCP localhost:8889->localhost:48971 (CLOSE_WAIT)
java       1443 spot   27u  IPv4 9974682      0t0  TCP localhost:8889->localhost:48978 (CLOSE_WAIT)
java       1443 spot   28u  IPv4 9981105      0t0  TCP localhost:8889->localhost:48994 (CLOSE_WAIT)
java       1443 spot   29u  IPv4 9984912      0t0  TCP localhost:8889->localhost:49009 (CLOSE_WAIT)
java       1443 spot   30u  IPv4 9986211      0t0  TCP localhost:8889->localhost:49010 (CLOSE_WAIT)
java       1443 spot   31u  IPv4 9991422      0t0  TCP localhost:8889->localhost:49053 (ESTABLISHED)
firefox-e 26692 root   72u  IPv4 9990734      0t0  TCP localhost:49053->localhos
If I try to kill the process tying up my port with fuser I get.

Code: Select all

# fuser -k 1443/tcp
Cannot stat file /proc/1443/fd/7: Stale file handle
Cannot stat file /proc/1443/fd/18: Stale file handle
if I navigate to the difectory:

Code: Select all

/proc/1443/fd/
I see the symlinks named 7 and 18 are broken. Can I just delete these two symlinks or will that mess somthing up?

Note that rebooting the computer solves the issue but I don't want to do that.

Peterm321
Posts: 411
Joined: Thu 29 Jan 2009, 14:09
Location: UK

#2 Post by Peterm321 »

I cannot comment reliably on freenet itself (I don't use). I am getting similar stale file handle message when I UMOUNT for example a USB thumb drive.

I tend to ignore them as I am assuming stale file handles are orphaned entries which will not interfere with the system.

What I would say on killing processes is after determining the PID of the process I tend to prefer to send the process the HUP signal first in the hope that this is the cleanest way to tell a process to terminate gracefully. If HUP does not close it then perhaps SIGINT or SIGTERM and as a last resort SIGKILL, see

Code: Select all

kill -l
for a list of signals.

Post Reply