This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug manual/22590] New: Job Control Shell mark_process_status always returns -1


https://sourceware.org/bugzilla/show_bug.cgi?id=22590

            Bug ID: 22590
           Summary: Job Control Shell mark_process_status always returns
                    -1
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: manual
          Assignee: unassigned at sourceware dot org
          Reporter: bob.hn.gardner at gmail dot com
                CC: mtk.manpages at gmail dot com
  Target Milestone: ---

First off, the manual is really excellent, thank you to everyone involved.

Section 28.6.2 Initializing the Shell sets the signal handler for SIGCHLD to
SIG_IGN, but does not explain why.

As a consequence, in Section 28.6.5 Stopped and Terminated Jobs, wait_for_job
always calls mark_process_status with pid=-1 and status=ECHILD, causing jobs in
the first_job linked list to never get updated.

This is the correct behavior given POSIX:

> If the parent process of the calling process has set its SA_NOCLDWAIT flag or has set the action for the SIGCHLD signal to SIG_IGN:
> ...
> If a thread in the parent process of the calling process is blocked in wait(), waitpid(), or waitid(), and the parent process has no remaining child processes in the set of waited-for children, the wait(), waitid(), or waitpid() function shall fail and set errno to [ECHILD].

http://pubs.opengroup.org/onlinepubs/9699919799/

The paragraphs above the example in Section 28.6.5 Stopped and Terminated Jobs
do call out installing/uninstalling the signal handler for SIGCHLD during
specific times of the program's execution. However, it does not document this
issue.

Potential Patches:

1. Remove the `signal (SIGCHLD, SIG_IGN);` line from Section 28.6.2
Initializing the Shell
2. Reset the signal handler for SIGCHLD back to SIG_IGN before calling waitpid
in update_status and wait_for_job and use this as an opportunity to explain
this behavior as an edit to the documentation in Section 28.6.5 Stopped and
Terminated Jobs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]