X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=hooks.c;h=59c5807065fc4ee58974a7eec196c7335bcbb8e3;hp=44ee41980085c5383c8f9d617fa63764d410110f;hb=33382c2b5ba2537952a60ea378feff36961e4713;hpb=d399b6b909fe6e2c6073464006061382c8bb31d5 diff --git a/hooks.c b/hooks.c index 44ee4198..59c58070 100644 --- a/hooks.c +++ b/hooks.c @@ -15,7 +15,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/ . + * along with this program. If not, see https://www.gnu.org/licenses/ . * * Author: Jani Nikula */ @@ -50,7 +50,10 @@ notmuch_run_hook (const char *db_path, const char *hook) goto DONE; } - pid = fork(); + /* Flush any buffered output before forking. */ + fflush (stdout); + + pid = fork (); if (pid == -1) { fprintf (stderr, "Error: %s hook fork failed: %s\n", hook, strerror (errno)); @@ -75,7 +78,7 @@ notmuch_run_hook (const char *db_path, const char *hook) goto DONE; } - if (!WIFEXITED (status) || WEXITSTATUS (status)) { + if (! WIFEXITED (status) || WEXITSTATUS (status)) { if (WIFEXITED (status)) { fprintf (stderr, "Error: %s hook failed with status %d\n", hook, WEXITSTATUS (status));