dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: DASH shell mailing list <dash@vger.kernel.org>
Subject: Re: dash 0.5.11.2: somehow falsely waits
Date: Mon, 21 Dec 2020 20:36:21 +0100	[thread overview]
Message-ID: <20201221193621.eKxnM%steffen@sdaoden.eu> (raw)
In-Reply-To: <20201220014300.8lXtI%steffen@sdaoden.eu>

Hello on a Monday.

Steffen Nurpmeso wrote in
 <20201220014300.8lXtI%steffen@sdaoden.eu>:
 |There is another issue with at least dash (the others not yet
 |tested).  I cloned the git repo and it is still present at
 |6ba88b3ed28fb4b52f20b730194c4ad3d8aad037.
 |
 |With the original test script of what is in "Re: dash 0.5.11.2,
 |busybox sh 1.32.0, FreeBSD 12.2 sh: spring TTOU but should not
 |i think" the sleeper will randomly wake too early for whatever
 |reason.  The sleeper is:
 |
 |  i=
 |  trap 'i=1' USR1 # "reaper (actually a notify timer only) is up"
 |  (
 |      parent=${$}
 |      sleeper= int=0 hot=0
 |      trap '' EXIT HUP QUIT CHLD
 |      trap 'exit 0' INT
 |      trap '
 |         int=1 hot=1
 |         [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
 |      ' USR1
 |      trap '
 |         int=1 hot=0
 |         [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
 |      ' USR2
 |      trap '
 |         [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
 |         echo "Stopping job reaper"
 |         exit 0
 |      ' TERM
 |
 |      # traps are setup, notify parent that we are up and running
 |      kill -USR1 ${parent} >/dev/null 2>&1
 |
 |      while :; do
 |         int=0
 |         /bin/sleep ${JOBWAIT} &
 |         sleeper=${!}
 |         wait ${sleeper}
 |         sleeper=
 |         [ "${int}${hot}" = 01 ] && kill -USR1 ${parent} >/dev/null 2>&1
 |      done
 |   ) </dev/null & #>/dev/null 2>&1 &
 |   JOBREAPER=${!}

What seems to work absolutely reliable on Linux is

   i=
   trap 'i=1' USR1 # "reaper (actually a notify timer only) is up"
   (
      parent=${$}
      sleeper=
      trap '' EXIT HUP QUIT CHLD
      trap 'exit 0' INT
      trap '
         (
            trap 'exit 1' TERM
            /bin/sleep ${JOBWAIT}
            kill -USR1 ${parent} >/dev/null 2>&1
         ) </dev/null &
         sleeper=${!}
      ' USR1
      trap '
         [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
         sleeper=
      ' USR2
      trap '
         [ -n "${sleeper}" ] && kill -TERM ${sleeper} >/dev/null 2>&1
         echo "Stopping job reaper"
         exit 0
      ' TERM

      # traps are setup, notify parent that we are up and running
      kill -USR1 ${parent} >/dev/null 2>&1

      while :; do
         sleep >/dev/null 2>&1
      done
   ) </dev/null & #>/dev/null 2>&1 &
   JOBREAPER=${!}

Unfortunately this causes all sorts of trouble on a lot of other
shells on Solaris at least, with and without backgrounding the
sleeper and waiting on it in the USR1 trap.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

  reply	other threads:[~2020-12-21 19:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-20  1:43 dash 0.5.11.2: somehow falsely waits Steffen Nurpmeso
2020-12-21 19:36 ` Steffen Nurpmeso [this message]
2020-12-21 19:58   ` Steffen Nurpmeso
2021-01-06  4:47 ` Herbert Xu
2021-01-06 20:44   ` Steffen Nurpmeso
2021-01-07  2:50     ` Herbert Xu
2021-01-07 19:00       ` Steffen Nurpmeso
2021-01-07 21:07         ` Herbert Xu
2021-01-07 21:48           ` Steffen Nurpmeso

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=20201221193621.eKxnM%steffen@sdaoden.eu \
    --to=steffen@sdaoden.eu \
    --cc=dash@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).