gspawn: Handle error opening /dev/null

This is very unlikely to happen, but add error handling to mirror the
other calls to `safe_open()`, and shut Coverity up.

Coverity CID: #1430611

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2020-10-05 12:31:28 +01:00
parent ce005e83c6
commit f0e74a97e7

View File

@ -1451,6 +1451,9 @@ do_exec (gint child_err_report_fd,
else if (stderr_to_null) else if (stderr_to_null)
{ {
gint write_null = safe_open ("/dev/null", O_WRONLY); gint write_null = safe_open ("/dev/null", O_WRONLY);
if (write_null < 0)
write_err_and_exit (child_err_report_fd,
CHILD_DUP2_FAILED);
safe_dup2 (write_null, 2); safe_dup2 (write_null, 2);
close_and_invalidate (&write_null); close_and_invalidate (&write_null);
} }