diff options
author | Keith Packard <keithp@keithp.com> | 2012-06-14 15:09:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-06-14 15:09:25 -0700 |
commit | a0be4efca8c7163eb10a1dbab008e119a70de81c (patch) | |
tree | 79d202ace7813058a07fd9a3bacc6bd72bd355c7 | |
parent | bb20e90bd894ecf4efeba209af9536ec8d922538 (diff) |
Both the signal handler and main close the output if it's not stdout;
if you do both, then fclose gets called twice, which annoys libc.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | tools/evemu-record.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/tools/evemu-record.c b/tools/evemu-record.c index a046150..d708989 100644 --- a/tools/evemu-record.c +++ b/tools/evemu-record.c @@ -54,8 +54,10 @@ FILE *output; static void handler (int sig __attribute__((unused))) { fflush(output); - if (output != stdout) + if (output != stdout) { fclose(output); + output = stdout; + } } int main(int argc, char *argv[]) @@ -97,7 +99,9 @@ int main(int argc, char *argv[]) fprintf(stderr, "error: could not describe device\n"); } close(fd); - if (output != stdout) + if (output != stdout) { fclose(output); + output = stdout; + } return 0; } |