]> git.ipfire.org Git - thirdparty/coreutils.git/commit
sort: fix some --compress reaper bugs
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Dec 2010 07:23:17 +0000 (23:23 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 14 Dec 2010 07:23:47 +0000 (23:23 -0800)
commit0da4d843003e9d38624e19c24c7fb670f1bb4749
treed3dec25ace480315613643c1cced91a23d8c49b4
parent6d36bd4c6418083d543c3757905c3202f2d0ee43
sort: fix some --compress reaper bugs

* src/sort.c (uintptr): New type.
(enum procstate, struct procnode, update_proc): Remove.
(proctab_hasher, proctab_comparator, register_proc, wait_proc):
(reap_some): The proctab is now simply a hash of process-IDs
rather than of pointers to objects with reference counts and
states; this is smaller and faster and easier to understand.
(nprocs): Now pid_t, not size_t, since one cannot have more than
PID_MAX children.
(reap): If the argument is -1, wait; if 0 (a new value), do not.
Delete pid from proctab as needed.  Ignore children that are not
in proctab, as they are from the program that exec'ed us and are
irrelevant to our success or failure.
(delete_proc, reap_all): New functions.
(open_temp): Register the child.
(sort): Clean up all children afterwards; without this patch,
'sort' sometimes missed failures in children due to race conditions.
* tests/Makefile.am (TESTS): Add misc/sort-compress-proc.
* tests/misc/sort-compress-proc: New file, to test for the
bugs fixed above.
src/sort.c
tests/Makefile.am
tests/misc/sort-compress-proc [new file with mode: 0755]