All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Martin Shepherd <mcs@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-help] Xeno-test bug
Date: Sun, 12 Apr 2009 21:25:57 +0200	[thread overview]
Message-ID: <49E24045.4060204@domain.hid> (raw)
In-Reply-To: <Pine.LNX.4.64.0904121117380.23562@domain.hid>

Martin Shepherd wrote:
> On Sun, 12 Apr 2009, Gilles Chanteperdrix wrote:
>> No, that is the intended behaviour, as the name "cleanup_load" suggests,
>> cleanup_load is intended to be called when generate_load terminates.
> 
> I think that you mean "when the dd process that generate_loads() runs,
> terminates", not when generate_loads() itself ends. Generate_loads is
> supposed to end as soon as it has started the specified number of dd
> processes in a background.
> 
>> The
>> real problem is to know why generate_loads terminates early. Maybe you
>> have not installed dd ?
> 
> No, dd is started, and continues to run fine in the background, even
> after the EXIT handler is triggered. What I found was that the EXIT
> handler was not being triggered by dd terminating, but because the
> generate_loads() procedure which starts it, is executed in a
> sub-shell, which terminates.
> 
> Removing extraneous code, the problematic statements of the script are
> as follows:
> 
>     loudly() {
>         eval $* &
>         wait $!
>     }
> 
>     mkload() { dd if=$device of=/dev/null $* & }
> 
>     generate_loads() {
>         loudly mkload
>     }
> 
>     generate_loads
> 
> When generate_loads() is executed above, it calls loudly(), telling it
> to execute mkload(). For some reason, loudly() does this as follows:
> 
>   eval mkload &
> 
> which, if one expands the definition of mkload(), is equivalent to:
> 
>   (dd if=$device of=/dev/null $* &) &
> 
> In other words, the "eval mkload &" statement starts mkload() within a
> background process, then mkload() also starts the dd in a second
> background process. The background dd process then continues, while the
> process that started it terminates normally, and triggers the EXIT
> handler.
> 
> This happens because loudly() is implemented like:
> 
>      loudly() {
>          eval $* &
>          wait $!
>      }
> 
> instead of the more obvious:
> 
>      loudly() {
>          eval $*
>      }

Ok. Thanks for taking the time to debug this. If you made modifications
(other than replacing #!/bin/sh with #!/bin/bash) which make xeno-test
run in your case, send a patch which we will be happy to merge.

-- 
					    Gilles.


  reply	other threads:[~2009-04-12 19:25 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-08 23:08 [Xenomai-help] Selecting the TSC Martin Shepherd
2009-04-09  0:11 ` Martin Shepherd
2009-04-09  2:49   ` Steven Seeger
2009-04-10 22:15   ` [Xenomai-help] Xeno-test bug Martin Shepherd
2009-04-11  0:20     ` [Xenomai-help] Running xeno-test Martin Shepherd
2009-04-11  0:24       ` Steven Seeger
2009-04-11  0:35         ` Martin Shepherd
2009-04-11 12:39           ` Gilles Chanteperdrix
2009-04-11 20:00             ` Martin Shepherd
2009-04-11 20:07               ` Gilles Chanteperdrix
2009-04-12  2:02                 ` Martin Shepherd
2009-04-12  9:11                   ` Gilles Chanteperdrix
2009-04-12 17:40                     ` Gilles Chanteperdrix
2009-04-12 19:10                     ` Martin Shepherd
2009-04-12 19:23                       ` Gilles Chanteperdrix
2009-04-16  3:20                         ` Martin Shepherd
     [not found]                           ` <4F0B1E98-862D-4031-B22E-D7DAEA554EEB@comcast.net>
     [not found]                             ` <Pine.LNX.4.64.0904161059220.24221@domain.hid>
2009-04-16 18:43                               ` Steven Seeger
2009-04-16 22:18                                 ` Martin Shepherd
2009-04-17  2:50                                 ` Martin Shepherd
     [not found]                           ` <1239872431.5845.25.camel@domain.hid>
     [not found]                             ` <Pine.LNX.4.64.0904161537400.26955@domain.hid>
2009-04-17  8:01                               ` Vikesh Rambaran
2009-04-17 12:57                           ` Gilles Chanteperdrix
2009-04-17 23:34                             ` Martin Shepherd
2009-04-19  5:15                             ` Martin Shepherd
2009-04-12 10:31     ` [Xenomai-help] Xeno-test bug Gilles Chanteperdrix
2009-04-12 10:36     ` Gilles Chanteperdrix
2009-04-12 18:52       ` Martin Shepherd
2009-04-12 19:25         ` Gilles Chanteperdrix [this message]
2009-04-13  0:42           ` Martin Shepherd

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=49E24045.4060204@domain.hid \
    --to=gilles.chanteperdrix@xenomai.org \
    --cc=mcs@domain.hid \
    --cc=xenomai@xenomai.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.