awk doesn't wait for subordinate processes to complete

Jeff Stearns jeff at fluke.UUCP
Wed Nov 28 08:40:09 AEST 1984


Index:	 usr.bin/awk 4.2BSD

Description:
	If one redirects awk output through a filter, awk does not wait
	for the filter to terminate before awk itself terminates.  The
	output therefore appears asynchronously while subsequent commands
	are being processed.  In a shell script, this can be fatal if the
	filter is, for example, sort(1).

Repeat-By:
	% awk 'END { print "echo hi" | "sh" }' </dev/null
	
	Note that the result is (usually):
	    % awk 'END { print "echo hi" | "sh" }' </dev/null
	    % hi

	rather than:
	    % awk 'END { print "echo hi" | "sh" }' </dev/null
	    hi
	    %

	Try this, and note the changing size of the sorted-output file:	
	    % awk '{ print $0 | "sort -o sorted-output" }' <big-file
	    % wc sorted-output
	    % wc sorted-output
	    % wc sorted-output
	    % wc sorted-output
Fix:
	(Suggestion only)
	Before exiting, awk should call pclose(3) on each stream pointer
	which was created via a popen(3) in run.c.  The pclose(3) will
	wait(3) on the subordinate child before returning.
-- 
	Jeff Stearns       (206) 356-5064
	John Fluke Mfg. Co.
	P.O. Box C9090  Everett WA  98043  
	{uw-beaver,decvax!microsof,ucbvax!lbl-csam,allegra,ssc-vax}!fluke!jeff



More information about the Comp.bugs.4bsd.ucb-fixes mailing list