debug_return_int(cstat->type == CMD_ERRNO ? -1 : 0);
}
-/*
- * Open a pipe and make both ends non-blocking.
- * Returns 0 on success and -1 on error.
- */
-int
-pipe_nonblock(int fds[2])
-{
- int flags, ret;
- debug_decl(pipe_nonblock, SUDO_DEBUG_EXEC)
-
- ret = pipe(fds);
- if (ret != -1) {
- flags = fcntl(fds[0], F_GETFL, 0);
- if (flags != -1 && !ISSET(flags, O_NONBLOCK))
- ret = fcntl(fds[0], F_SETFL, flags | O_NONBLOCK);
- if (ret != -1) {
- flags = fcntl(fds[1], F_GETFL, 0);
- if (flags != -1 && !ISSET(flags, O_NONBLOCK))
- ret = fcntl(fds[1], F_SETFL, flags | O_NONBLOCK);
- }
- if (ret == -1) {
- close(fds[0]);
- close(fds[1]);
- }
- }
-
- debug_return_int(ret);
-}
-
/*
* Kill command with increasing urgency.
*/
* We use a pipe to atomically handle signal notification within
* the event loop.
*/
- if (pipe_nonblock(signal_pipe) != 0)
+ if (pipe2(signal_pipe, O_NONBLOCK) != 0)
sudo_fatal(U_("unable to create pipe"));
/* Reset SIGWINCH and SIGALRM. */
#endif /* HAVE_STRINGS_H */
#include <unistd.h>
#include <errno.h>
+#include <fcntl.h>
#include <signal.h>
#include "sudo.h"
* We use a pipe to atomically handle signal notification within
* the select() loop without races (we may not have pselect()).
*/
- if (pipe_nonblock(signal_pipe) != 0)
+ if (pipe2(signal_pipe, O_NONBLOCK) != 0)
sudo_fatal(U_("unable to create pipe"));
memset(&sa, 0, sizeof(sa));
struct sudo_conv_callback *callback);
/* exec.c */
-int pipe_nonblock(int fds[2]);
int sudo_execute(struct command_details *details, struct command_status *cstat);
/* parse_args.c */