Skip to content

Commit

Permalink
Changed error checking macros used in the child process in ‘tty_spawn…
Browse files Browse the repository at this point in the history
…’ to use ‘_exit’ instead of ‘exit’, and ‘dprintf’ instead of ‘printf’, to avoid flushing the open streams copied, buffers included, from the parent process.
  • Loading branch information
Rinzwind committed Mar 14, 2024
1 parent c87a273 commit 6fa0c9e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tty/tty.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#define _XOPEN_SOURCE 700
#endif

#include <errno.h>
Expand All @@ -13,16 +13,16 @@
#define STATUS_ERROR 127
#define CHECK_NULL(exp) \
if ((exp) == NULL) { \
exit(STATUS_ERROR); \
_exit(STATUS_ERROR); \
}
#define CHECK_ERROR(exp) \
if ((exp) == -1) { \
exit(STATUS_ERROR); \
_exit(STATUS_ERROR); \
}
#define CHECK_ERROR_PRINT(exp) \
if ((exp) == -1) { \
printf("Error in %s at %s: %s\n", __func__, #exp, strerror(errno)); \
exit(STATUS_ERROR); \
dprintf(2, "Error in %s at %s: %s\n", __func__, #exp, strerror(errno)); \
_exit(STATUS_ERROR); \
}

pid_t tty_spawn(int fdm, const char *path, char *const argv[], char *const envp[])
Expand Down

0 comments on commit 6fa0c9e

Please sign in to comment.