From: Andreas Jellinghaus <aj@dungeon.inka.de>
To: linux-kernel@vger.kernel.org
Subject: 2.5.61/usb: poll does not time out
Date: 15 Feb 2003 20:55:01 +0100 [thread overview]
Message-ID: <1045338900.486.20.camel@simulacron> (raw)
Hi,
poll() should return as soon as there is some event.
unplugging a usb device will cause poll to set
revents to POLLERR|POLLHUP.
But the poll() syscall is not returned, instead
the kernel waits for the timeout to count down /
in the case poll with a negative value to wait
forever. This way an application will never
notice that the usb device has been removed.
here is a strace on a test app.
the kernel waits full 10 seconds (the timeout used),
even though the usb device was removed in the first
five seconds.
send(4, "<15>Feb 15 20:47:52 usbtoken[947"..., 52, 0) = 52
rt_sigaction(SIGPIPE, {SIG_DFL}, NULL, 8) = 0
poll([{fd=3, events=POLLIN|POLLPRI|POLLOUT|POLLERR,
revents=POLLERR|POLLHUP}], 1, 10000) = 1
time([1045338482]) = 1045338482
getpid() = 9477
writev(2, [{"usbtoken[9477]: device removed. "..., 41}],
1usbtoken[9477]: device removed. exiting.
) = 41
rt_sigaction(SIGPIPE, {0x400edf48, [], 0x4000000}, {SIG_DFL}, 8) = 0
send(4, "<15>Feb 15 20:48:02 usbtoken[947"..., 61, 0) = 61
was it meant to be that way?
if so: how can i work around this (in a nice way) ?
i could:
a) use short timeouts and a permanent loop (not nice)
b) use the hotplug script when it is called with "remove"
to find the app with which has the device still open
and kill the process / send some signal. also not nice.
Andreas
reply other threads:[~2003-02-15 19:42 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1045338900.486.20.camel@simulacron \
--to=aj@dungeon.inka.de \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.