This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug manual/792] New: Error in example code on job control in Glibs manual
- From: "axel at liljencrantz dot se" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 17 Mar 2005 11:43:47 -0000
- Subject: [Bug manual/792] New: Error in example code on job control in Glibs manual
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
The page "Job Control/Implementing a shell/Launching Jobs" contains a code
snippet on how to launch a job. In this code snippet, a newly launched process
tries to call exec before it knows that the entire pipeline has been created.
This is a bug, because a process may change it's session or otherwise change it
status in a way that will make the shell unable to correctly set the process
group of the following programs in the pipeline. Simple pipelines like 'ls -la
--color|more' seem to break from this, which is strange since ls shouldn't do
anything strange. Therefore, each process should wait for the shell to tell them
that they can launch before calling exec. My proposed method for doing this is
to change the code snippet
if (pgid == 0) pgid = pid;
setpgid (pid, pgid);
if (foreground)
tcsetpgrp (shell_terminal, pgid);
into
while( getpgid(pid) != pgid )
sleep(0);
if (foreground)
{
while( tcgetpgrp( 0 ) != pgid )
sleep(0);
}
but there may be other issues with that code.
--
Summary: Error in example code on job control in Glibs manual
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: manual
AssignedTo: roland at gnu dot org
ReportedBy: axel at liljencrantz dot se
CC: glibc-bugs at sources dot redhat dot com
http://sources.redhat.com/bugzilla/show_bug.cgi?id=792
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.