commit 8e5b7b9435379bb3dffb58200f9bc5fdbd5d0309
parent f20795ee496838171baa1ec26fd4c16c1729b22e
Author: Nihal Jere <nihal@nihaljere.xyz>
Date: Sat, 25 Dec 2021 22:54:01 -0600
check errors on sigaction
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/npm-agent.c b/npm-agent.c
@@ -227,12 +227,26 @@ main()
.sa_handler = alarm_handler,
};
-
if (mlock(master, sizeof(master)) == -1) {
perror("failed to mlock master buffer");
goto error;
}
+ if (sigaction(SIGINT, &sa_term, NULL) == -1) {
+ perror("sigaction(SIGINT)");
+ goto error;
+ }
+
+ if (sigaction(SIGTERM, &sa_term, NULL) == -1) {
+ perror("sigaction(SIGTERM)");
+ goto error;
+ }
+
+ if (sigaction(SIGALRM, &sa_alarm, NULL) == -1) {
+ perror("sigaction(SIGALRM)");
+ goto error;
+ }
+
int sock = socket(AF_UNIX, SOCK_STREAM, 0);
if (sock == -1) {
perror("failed to create socket");