]> git.gir.st - forkaftergrep.git/blame_incremental - fag.1
Add notes about unbuffering
[forkaftergrep.git] / fag.1
... / ...
CommitLineData
1.TH fag 1 "16 February 2018" "1.2" "User Commands"
2.hy 0
3.SH NAME
4fag \- daemonize program after a pattern was matched (ForkAfterGrep)
5.
6.SH SYNOPSIS
7.B fag
8.RI [ OPTIONS ]
9.I PATTERN
10.I PROGRAM
11.RI [ ARGUMENTS .\|.\|.]
12.br
13.SH DESCRIPTION
14.B fag
15uses
16.B grep
17to search the output of
18.IR PROGRAM
19for the regular expression
20.IR PATTERN
21and daemonizes it when a match is found. The PID is then returned on stdout.
22.SH OPTIONS
23.SS "Behaviour Changing Options"
24.TP
25.BI \-t " SECONDS"
26Abort matching after
27.I SECONDS
28seconds and print
29.IR PROGRAM 's
30PID. Unless
31.BR \-k
32is given, PROGRAM is kept running and daemonized.
33.TP
34.BR \-k "[" \fISIGNAL\fP "]
35If the timeout
36.RB ( \-t )
37has been reached, send a signal to
38.IR PROGRAM .
39.I SIGNAL
40defaults to
41.BR SIGTERM " (15)."
42The signal may only be given as a number.
43.TP
44.BR \-r
45Search for
46.IR PATTERN
47on
48.BR stderr
49instead of
50.BR stdout .
51.TP
52.BI \-l " FILE "
53Log
54.IR PROGRAM 's
55.BR stdout
56to
57.IR FILE .
58The file will be opened in append mode. If the file does not exist, it will be created with file mode \fI0600\fR.
59.TP
60.BI \-L " FILE "
61Same as
62.BR \-l
63but logs
64.IR PROGRAM 's
65.BR stderr .
66.TP
67.BR \-V
68Be verbose; print
69.IR PROGRAM 's
70monitored stream
71to
72.BR stderr .
73.SS "Generic Program Information"
74.TP
75.B \-h
76Output a short usage message and exit.
77.TP
78.BR \-v
79Display version and copyright information and exit.
80.SS "Supported grep Options"
81.TP
82.BR \-E ", " \-F ", " \-G ", " \-P
83Matcher selection switches for extended regular expressions, fixed strings, basic regular expressions (default) or Perl-compatible regular expressions. At most one of them may be supplied.
84.TP
85.BR \-i ", " \-w ", " \-x ", " \-U
86Matching control switches for ignore case distinctions, whole words only, whole lines only and treat as binary.
87.TP
88.BR \-Z ", " \-J
89Decompression switches for
90.IR gzip (1)
91and
92.IR bzip2 (1).
93Not widely supported; check your
94.BR grep 's
95capabilities.
96.SH EXIT STATUS
97If
98.IR PATTERN
99was found, 0 is returned. Otherwise, the exit status follows the BSD guideline outlined in
100.B #include <sysexits.h>
101if the error occurred from within
102.B fag
103or in case the child process exits prematurely, its exit code is inherited. Notably, \fI69\fP is returned when the timeout is reached.
104.SH BUGS
105.SS Known Bugs
106logging stops when a timeout is reached.
107.PP
108if grep gets killed (e.g. `killall grep'), fag should terminate.
109.SS Reporting Bugs
110Please report bugs and patches to the issue tracker at https://github.com/girst/forkaftergrep/.
111.SH NOTES
112Usually,
113.B fag
114uses the
115.B grep
116supplied in the path. This behaviour can be overridden with the environment variable
117.IR GREP_OVERRIDE .
118.PP
119.B fag
120works best when
121.IR PROGRAM 's
122output is line-buffered.
123.BR stdbuf (1)
124from the GNU coreutils can adjust buffering options. If a program is still too clever,
125.BR script (1)
126creates a pty to wrap around a program.
127.PP
128Since 1.2, if
129.B fag
130gets interrupted or terminated before a match is found (or the timeout has been reached), this signal is passed to
131.IR PROGRAM .
132.PP
133In version 1.2 the command line switch
134.B \-e was renamed to
135.B \-r
136to avoid overloading
137.BR grep 's
138own switches. An error will be thrown when
139.BR \-e
140or
141.BR \-f
142is supplied as an argument.
143.SH COPYRIGHT
144Copyright 2017-2018 Tobias Girstmair. This is free software released under the terms of the GNU General Public License Version 3; see https://www.gnu.org/licenses/gpl-3.0.html for conditions.
145.SH AUTHOR
146Tobias Girstmair (https://gir.st/)
Imprint / Impressum