From: girst Date: Fri, 11 Aug 2017 23:23:03 +0000 (+0200) Subject: found bug, won't do mnemonic signals (for now) X-Git-Url: https://git.gir.st/forkaftergrep.git/commitdiff_plain/de1e8d30769be128c55741a83dd0b7084b88472d found bug, won't do mnemonic signals (for now) if grep crashes, it thinks, a match was found mnemonic signal support delayed (not very portable) --- diff --git a/fag.1 b/fag.1 index 3dd77d2..582da8a 100644 --- a/fag.1 +++ b/fag.1 @@ -66,16 +66,14 @@ if the error occured from within or in case the chid process exits prematurely, its exit code is inherited. Notably, \fI69\fP is returned when the timeout is reached. .SH BUGS .SS Known Bugs -.IR SIGNAL -needs to be given as an integer; mnemonic should be supported in the future. -.PP if grep exits with a code > 0, fag should terminate with grep's exit code and an error message. instead, fag exits as if a match was found. .PP Sometimes, stdin behaves strange after the program terminates. .SS Reporting Bugs Please report bugs and patches to the issue tracker at https://github.com/girst/forkaftergrep/. .SH NOTES -Some might find the name of this program offensive. Feel free to create a symlink or alias on your system. +.IR SIGNAL +needs to be given as an integer. implementing mnemonics is dirty and not very portable; maybe support in the future. .SH COPYRIGHT Copyright 2017 Tobias Girstmair. This is free software; see https://www.gnu.org/licenses/gpl-3.0.html for conditions. .SH AUTHOR diff --git a/fag.c b/fag.c index 39b8a96..cbf886d 100644 --- a/fag.c +++ b/fag.c @@ -1,5 +1,5 @@ /* forkaftergrep (C) 2017 Tobias Girstmair, GPLv3 */ -//TODO: `tee': bad file descriptor +//TODO: if grep exits with an error, fag thinks a match was found #define _XOPEN_SOURCE 500 #define _DEFAULT_SOURCE @@ -194,6 +194,7 @@ int fork_after_grep (struct opt opts) { write(grep_pipefd[1], buf, nbytes); /* can cause SIGPIPE if grep exited, therefore signal will be ignored */ } + // TODO: exits with `0' even if `grep' exits with code > 0 ! if (waitpid (grep_cpid, &grep_status, WNOHANG) > 0 && WIFEXITED (grep_status)) { close (grep_pipefd[1]);