aboutgitcodelistschat:MatrixIRC
diff options
context:
space:
mode:
authorAlice Frosi <afrosi@redhat.com>2023-03-28 16:19:36 +0200
committerAlice Frosi <afrosi@redhat.com>2023-03-28 16:19:36 +0200
commit21c4730f0cb020db3bdff22e347a52d012cc79fe (patch)
treedacc95dfd393d07586e4cb432a930f7e0503c95b
parent667c6db3425881d1201e7ae7a05cef7ca7ca94b1 (diff)
downloadseitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.tar
seitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.tar.gz
seitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.tar.bz2
seitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.tar.lz
seitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.tar.xz
seitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.tar.zst
seitan-21c4730f0cb020db3bdff22e347a52d012cc79fe.zip
seitan: use die function to terminate on error
-rw-r--r--seitan.c28
1 files changed, 10 insertions, 18 deletions
diff --git a/seitan.c b/seitan.c
index b6e640d..6dfbe14 100644
--- a/seitan.c
+++ b/seitan.c
@@ -185,10 +185,8 @@ static int pidfd_send_signal(int pidfd, int sig, siginfo_t *info,
static void unblock_eater(int pidfd)
{
- if (pidfd_send_signal(pidfd, SIGCONT, NULL, 0) == -1) {
- perror("pidfd_send_signal");
- exit(EXIT_FAILURE);
- }
+ if (pidfd_send_signal(pidfd, SIGCONT, NULL, 0) == -1)
+ die(" pidfd_send_signal");
}
static int create_socket(const char *path)
@@ -308,9 +306,9 @@ int main(int argc, char **argv)
} else if (strcmp(arguments.socket, "") > 0) {
unlink(arguments.socket);
if ((fd = create_socket(arguments.socket)) < 0)
- exit(EXIT_FAILURE);
+ die(" creating the socket");
if ((notifier = recvfd(fd)) < 0)
- exit(EXIT_FAILURE);
+ die(" failed recieving the notifier fd");
} else {
while ((ret = event(s)) == -EAGAIN)
;
@@ -319,23 +317,17 @@ int main(int argc, char **argv)
}
sleep(1);
- if ((epollfd = epoll_create1(0)) < 0) {
- perror("epoll_create");
- exit(EXIT_FAILURE);
- }
+ if ((epollfd = epoll_create1(0)) < 0)
+ die(" epoll_create");
ev.events = EPOLLIN;
ev.data.fd = notifier;
- if (epoll_ctl(epollfd, EPOLL_CTL_ADD, notifier, &ev) == -1) {
- perror("epoll_ctl: notifier");
- exit(EXIT_FAILURE);
- }
+ if (epoll_ctl(epollfd, EPOLL_CTL_ADD, notifier, &ev) == -1)
+ die(" epoll_ctl: notifier");
while (running) {
nevents = epoll_wait(epollfd, events, EPOLL_EVENTS, -1);
- if (nevents < 0) {
- perror("epoll_wait");
- exit(EXIT_FAILURE);
- }
+ if (nevents < 0)
+ die(" waiting for seccomp events");
memset(req, 0, sizeof(*req));
if (ioctl(notifier, SECCOMP_IOCTL_NOTIF_RECV, req) < 0)
die(" recieving seccomp notification");