diff options
author | Austin Clements <amdragon@MIT.EDU> | 2014-03-23 17:22:26 -0400 |
---|---|---|
committer | David Bremner <david@tethera.net> | 2014-03-25 21:22:17 -0300 |
commit | 03680d10066f85887c1198925a7b297b27435919 (patch) | |
tree | 5ae216b53ca2251e5e65798af51c5d3b5f054ee6 | |
parent | 31a6333aa46fc8125d2fe1effd6fddf48e47c14e (diff) |
cli: Flush stdout before fork()ing to run hooks
Without this flush, if stdout is block buffered (which will happen if
it's a pipe or a file, for example) and the hook also writes to
stdout, then notmuch new's output will appear *after* the hook output.
This situation may be a little esoteric, but it's good practice to
flush before you fork anyway.
-rw-r--r-- | hooks.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -50,6 +50,9 @@ notmuch_run_hook (const char *db_path, const char *hook) goto DONE; } + /* Flush any buffered output before forking. */ + fflush (stdout); + pid = fork(); if (pid == -1) { fprintf (stderr, "Error: %s hook fork failed: %s\n", hook, |