Skip to content

Commit

Permalink
Make -1, --one-event return $? when killed
Browse files Browse the repository at this point in the history
  • Loading branch information
DabeDotCom authored and emcrisostomo committed Dec 23, 2024
1 parent 0e67ba5 commit 831f366
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions fswatch/src/fswatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ extern "C" void close_handler(int signal)
{
FSW_ELOG(_("Executing termination handler.\n"));
close_monitor();

if (_1flag)
{
exit(128 + signal);
}
}

static bool parse_event_bitmask(const char *optarg)
Expand Down
6 changes: 5 additions & 1 deletion man/fswatch.7.in
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,16 @@ A space-separated list of
).
.El
.Pp
By default,
.Nm
enters an infinite loop and never returns. When it receives a SIGABRT, SIGINT
or SIGTERM signal,
.Nm
closes the notification streams and exits gracefully returning 0 to the calling
process.
process. (Unless running in
.Op Fl 1, -one-event
mode, in which case it sets its return code according to the signal it
received, as usual.)
.Pp
The following options are available:
.Bl -tag -width indent
Expand Down

0 comments on commit 831f366

Please sign in to comment.