From 66e905b7dd0f4e9dd576be681f30fbaeeb19ec4a Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Wed, 25 Aug 2021 22:16:46 +0200 Subject: use xopen() to handle fatal open(2) failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add and apply a semantic patch for using xopen() instead of calling open(2) and die() or die_errno() explicitly. This makes the error messages more consistent and shortens the code. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- run-command.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'run-command.c') diff --git a/run-command.c b/run-command.c index f72e72cce7..2961f7e55e 100644 --- a/run-command.c +++ b/run-command.c @@ -761,9 +761,7 @@ fail_pipe: notify_pipe[0] = notify_pipe[1] = -1; if (cmd->no_stdin || cmd->no_stdout || cmd->no_stderr) { - null_fd = open("/dev/null", O_RDWR | O_CLOEXEC); - if (null_fd < 0) - die_errno(_("open /dev/null failed")); + null_fd = xopen("/dev/null", O_RDWR | O_CLOEXEC); set_cloexec(null_fd); } -- cgit v1.3