RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 962755 - lsof command hangs on a system with unavailable NFS share.
Summary: lsof command hangs on a system with unavailable NFS share.
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lsof
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Peter Schiffer
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-05-14 11:45 UTC by Lukas Pramuk
Modified: 2014-10-16 12:22 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-15 14:29:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Lukas Pramuk 2013-05-14 11:45:45 UTC
Description of problem:
lsof command hangs on a system with unavailable NFS share.

Version-Release number of selected component (if applicable):
lsof-4.82-4.el6.x86_64

How reproducible:
100%

Steps to Reproduce:
1. mount nfs share to a machine (any mountpoint, any exported path)
2. make nfs share unavailable (poweroff exporting machine, suspend exporting guest, ...)
3. run any of lsof, lsof /path, lsof -p PID 
( lsof -i PORT is not affected )


Actual results:
lsof hangs

Expected results:
lsof ends up in reasonable time

Comment 3 Jan Pazdziora (Red Hat) 2013-05-14 11:59:38 UTC
I'd add that this bug report is a spin-off from bug 961463 and that our use of lsof in the Satellite code base is

   lsof -t -i TCP:8005 -p 31789

And the strange thing is that the above command blocks while merely doing

   lsof -t -i TCP:8005 | grep '^31789$'

does not block. It's a bit counterintuitive that a less specific lsof command would run fine while the more specific (which should be able to touch less /proc files or whatever lsof is using) blocks.

Comment 4 RHEL Program Management 2013-10-13 23:37:19 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.

Comment 5 Peter Schiffer 2014-10-15 14:29:18 UTC
Hi guys,

really sorry for such a late response, but here it is:

Jan:

those two commands are not equivalent. By default, lsof is doing an OR on options. Equivalent lsof version of grep command would be:

$ lsof -t -a -i TCP:8005 -p 31789

(but that would also block because lsof is scanning mount points for the -p option)


Anyway, blocking issue is well known for lsof and it tries to handle it with multiple ways. There are 3 sections in lsof(8) man page discussing this issue (BLOCKS AND TIMEOUTS, AVOIDING KERNEL BLOCKS and ALTERNATE DEVICE NUMBERS).

Long story short, the blocking is done on the kernel side, in one of the lstat(2), readlink(2) and stat(2) syscalls. lsof tries to avoid block by using timers and child processes, where you can control the length of the timer via -S option (default 15 seconds), however, this does not work for me. Another possibility is to use -b option, which tells to lsof to avoid mentioned syscalls and which for me, works great.

Comment 6 Jan Pazdziora (Red Hat) 2014-10-16 12:22:49 UTC
(In reply to Peter Schiffer from comment #5)
> 
> Long story short, the blocking is done on the kernel side, in one of the
> lstat(2), readlink(2) and stat(2) syscalls. lsof tries to avoid block by
> using timers and child processes, where you can control the length of the
> timer via -S option (default 15 seconds), however, this does not work for
> me. Another possibility is to use -b option, which tells to lsof to avoid
> mentioned syscalls and which for me, works great.

Thank you for the explanation.


Note You need to log in before you can comment on or make changes to this bug.