mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-23 19:38:07 +01:00
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.
This commit is contained in:
parent
31a6333aa4
commit
03680d1006
1 changed files with 3 additions and 0 deletions
3
hooks.c
3
hooks.c
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue