Bug 152132

Summary: script(1): [patch] Useless code in script.c (part 2)
Product: Base System Reporter: Ronald F. Guilmette <rfg>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me Keywords: patch
Priority: Normal    
Version: 7.0-RELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Ronald F. Guilmette 2010-11-11 06:20:09 UTC
	There appears to be a bunch of utterly useless (and perhaps even
	time wasting) code in script.c, and specifically within the
	finish() function.

	In that function there is a loop that reaps all child processes that
	are immediately available for reaping.  But this must be a leftover
	from an earlier time when script.c was implemented with -two- child
	processes.  Nowadays, it uses only one child process, i.e. the
	child shell process.  So it makes no sense to loop while trying to
	reap multiple child processes, because there is at most only one,
	the child shell process (and so it isn't even necessary or useful
	to call wait3() because a simple call to wait() should do.)

	Furthermore, if the idea is to reap the one and only child process,
	then before the reaping attempt even begins something positive
	should be done to cause the child to understand that it should exit
	now, i.e. calling close() on the "master" pty fd, i.e. just prior to
	all places in the code where the finish() function (or the done()
	function) is about to be called.  That should cause the child (shell)
	process to receive EOF on stdin/stdout/stderr, and that will probably
	cause it to figure out that it is time to go bye bye (if it hasn't
	done so already).

How-To-Repeat: 	Look at the code.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:01:05 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 2 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:35:44 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>