linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
To: linux-hotplug@vger.kernel.org
Subject: Re: [PATCH v2] udevd: don't use alarm() for timeouts
Date: Wed, 27 May 2009 08:57:07 +0000	[thread overview]
Message-ID: <4A1D0063.8090600@tuffmail.co.uk> (raw)
In-Reply-To: <4A1BC506.3090804@tuffmail.co.uk>

Kay Sievers wrote:

<Snip.  Apologies for snipping all your questions. I think it's become a
little confused and this is the most important issue.>

[Could run_program() avoid forking twice in a threaded udevd, and kill
timed-out commands so they don't become zombies when they eventually
finish?]

> On Tue, May 26, 2009 at 20:05, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
>   
>> There are other workarounds for the lack of a timeout in sys_wait(), so
>> I don't think that's a problem.  We can require that commands close
>> stdout & stderr pipes when they exit - i.e. do not pass them on to a
>> long-running child.  (At the moment there's a debian script "net.agent"
>> which has to do this for debug mode - it would need fixing to always do it).
>>     
>
> I don't think we can really assume anything from called programs. :)
>
> Thanks,
> Kay
>   

Sounds like the voice of experience.

The main constraint I'm working around is the lack of a timeout in
sys_wait*().  Forking twice allows the parent process to block on a pipe
instead, and use a select() timeout.

If we don't want to fork twice, and we can't rely on EOF on the
command's stdout pipe, I think the only alternative is to wait for
SIGCHLD.  The signal handler would check for finished PIDs with WNOHANG,
and look them up in a list to see which thread needs waking up.  In that
case, it's not essential to kill timed out commands.  The signal handler
can reap them just as easily as it reaps a command which is being waited
for by an event.

Forking twice is simpler though.  It's more direct, and it also easily
works with threading disabled.  At the moment my thread-specific code is
reasonably contained.  I have a ./configure option which switches back
to using separate processes, in case pthreads support is missing or
broken on some platforms.

Thanks
Alan

      parent reply	other threads:[~2009-05-27  8:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 10:31 [PATCH v2] udevd: don't use alarm() for timeouts Alan Jenkins
2009-05-26 15:37 ` Kay Sievers
2009-05-26 18:05 ` Alan Jenkins
2009-05-26 18:38 ` Kay Sievers
2009-05-27  8:57 ` Alan Jenkins [this message]

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=4A1D0063.8090600@tuffmail.co.uk \
    --to=alan-jenkins@tuffmail.co.uk \
    --cc=linux-hotplug@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).