Skip to content

Commit

Permalink
srp_daemon: Use pipe2 instead of pip&fcntl
Browse files Browse the repository at this point in the history
Just make a nonblocking pipe directly.

Signed-off-by: Jason Gunthorpe <[email protected]>
  • Loading branch information
jgunthorpe committed Aug 29, 2017
1 parent 6aad407 commit ac3036e
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions srp_daemon/srp_daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,36 +1998,19 @@ static int setup_wakeup_fd(void)
{
struct sigaction sa = {};
int ret;
int i;
int flags;

ret = pipe(wakeup_pipe);
ret = pipe2(wakeup_pipe, O_NONBLOCK | O_CLOEXEC);
if (ret < 0) {
pr_err("could not create pipe\n");
return -1;
}
for (i = 0; i < 2; i++) {
flags = fcntl(wakeup_pipe[i], F_GETFL);
if (flags < 0) {
pr_err("fcntl F_GETFL failed for %d\n", wakeup_pipe[i]);
goto close_pipe;
}
if (fcntl(wakeup_pipe[i], F_SETFL, flags | O_NONBLOCK) < 0) {
pr_err("fcntl F_SETFL failed for %d\n", wakeup_pipe[i]);
goto close_pipe;
}
}

sigemptyset(&sa.sa_mask);
sa.sa_handler = signal_handler;
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
sigaction(SRP_CATAS_ERR, &sa, NULL);
return 0;

close_pipe:
cleanup_wakeup_fd();
return -1;
}

static int ibsrpdm(int argc, char *argv[])
Expand Down

0 comments on commit ac3036e

Please sign in to comment.