bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

"wait" command should wait until process TERMINATES


From: Fergus Henderson
Subject: "wait" command should wait until process TERMINATES
Date: Wed, 4 Mar 2009 15:54:03 -0500 (EST)

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
-DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
uname output: Linux fergus-warp.nyc.corp.google.com 
2.6.18.5-gg26workstation-mixed64-32 #1 SMP Mon Feb 11 16:45:49 PST 2008 x86_64 
GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.1
Patch Level: 17
Release Status: release

Description:
        According to POSIX.1 (both 2004 
<http://www.opengroup.org/onlinepubs/009695399/utilities/wait.html>
        and 2008 
<http://www.opengroup.org/onlinepubs/9699919799/utilities/wait.html> versions),
        the "wait" command should wait until the process TERMINATES.
        (The exact wording is "If one or more pid operands are specified
        that represent known process IDs, the wait utility shall wait
        until all of them have terminated.")

        The POSIX.1 standard also describes the "-o monitor" option, and
        mentions nothing about it having any effect on the "wait" utility.

        But in bash, if the "-o monitor" option is set, the wait command
        finishes when the named process CHANGES STATUS, e.g. due to SIGSTOP
        or SIGCONT, rather than until it TERMINATES.

        In other words, when "-o monitor" is set, the observed behaviour
        of the wait command is like using the WUNTRACED and WCONTINUED
        options to waitpid(), whereas the wait command ought to behave
        like waitpid() _without_ those options.

Repeat-By:
        #!/bin/bash
        set -o monitor
        sleep 5 &
        child1=$!
        (sleep 1; kill -STOP $child1; sleep 1; kill -CONT $child1) &
        child2=$!
        wait $child1
        if [ $? == 147 ]; then
          echo "TEST FAILED: wait returned 147 (=128+SIGSTOP)" >&2
          wait $child2
          exit 1
        else
          echo "TEST PASSED"
        fi

        This wait command should wait until the sleep process terminates, and 
then report its status
        as successful (0), so the script ought to print out "TEST PASSED".  But 
instead the wait
        command terminates as soon as the sleep process gets the SIGSTOP 
signal, and returns 147
        (i.e. 128 + SIGSTOP), so the test prints out "TEST FAILED".





reply via email to

[Prev in Thread] Current Thread [Next in Thread]