aboutsummaryrefslogtreecommitdiffstats
path: root/src/firemon/procevent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firemon/procevent.c')
-rw-r--r--src/firemon/procevent.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/firemon/procevent.c b/src/firemon/procevent.c
index ebcb7a72c..378bdefe9 100644
--- a/src/firemon/procevent.c
+++ b/src/firemon/procevent.c
@@ -150,10 +150,8 @@ doexit:
150static int procevent_netlink_setup(void) { 150static int procevent_netlink_setup(void) {
151 // open socket for process event connector 151 // open socket for process event connector
152 int sock; 152 int sock;
153 if ((sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR)) < 0) { 153 if ((sock = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR)) < 0)
154 fprintf(stderr, "Error: cannot open netlink socket\n"); 154 goto errexit;
155 exit(1);
156 }
157 155
158 // bind socket 156 // bind socket
159 struct sockaddr_nl addr; 157 struct sockaddr_nl addr;
@@ -161,10 +159,8 @@ static int procevent_netlink_setup(void) {
161 addr.nl_pid = getpid(); 159 addr.nl_pid = getpid();
162 addr.nl_family = AF_NETLINK; 160 addr.nl_family = AF_NETLINK;
163 addr.nl_groups = CN_IDX_PROC; 161 addr.nl_groups = CN_IDX_PROC;
164 if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { 162 if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0)
165 fprintf(stderr, "Error: cannot bind to netlink socket\n"); 163 goto errexit;
166 exit(1);
167 }
168 164
169 // send monitoring message 165 // send monitoring message
170 struct nlmsghdr nlmsghdr; 166 struct nlmsghdr nlmsghdr;
@@ -189,12 +185,13 @@ static int procevent_netlink_setup(void) {
189 iov[2].iov_base = &op; 185 iov[2].iov_base = &op;
190 iov[2].iov_len = sizeof(op); 186 iov[2].iov_len = sizeof(op);
191 187
192 if (writev(sock, iov, 3) == -1) { 188 if (writev(sock, iov, 3) == -1)
193 fprintf(stderr, "Error: cannot write to netlink socket\n"); 189 goto errexit;
194 exit(1);
195 }
196 190
197 return sock; 191 return sock;
192errexit:
193 fprintf(stderr, "Error: netlink socket problem\n");
194 exit(1);
198} 195}
199 196
200 197