int fork_and_exec(char* file, char* cmd[]) {
pid_t pid = fork();
if (pid < 0) {
- fprintf(stderr, "could not fork: %m\n");
+ fprintf(stderr, "could not fork: %s\n", strerror(errno));
return GNUNET_SYSERR;
}
struct stat s;
if (stat("/sbin/iptables", &s) < 0) {
- fprintf(stderr, "stat on /sbin/iptables failed: %m\n");
+ fprintf(stderr, "stat on /sbin/iptables failed: %s\n", strerror(errno));
return GNUNET_SYSERR;
}
/* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
/* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr);
+ close(fd);
} /* }}} */
static void set_address4(char* dev, char* address, char* mask) { /* {{{ */
/* FIXME */ ioctl(fd, SIOCGIFFLAGS, &ifr);
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
/* FIXME */ ioctl(fd, SIOCSIFFLAGS, &ifr);
+ close(fd);
} /* }}} */
void setnonblocking(int fd) {/*{{{*/
int fd_tun = init_tun(dev);
if (fd_tun < 0) {
- fprintf(stderr, "Could not initialize tun-interface: %m\n");
+ fprintf(stderr, "Could not initialize tun-interface: %s\n", strerror(errno));
exit(1);
}
while(r < ntohs(hdr.size)) {
int t = write(1, buf, ntohs(hdr.size) - r);
if (t < 0) {
- fprintf(stderr, "write-error 1: %m, written %d/%d\n", r, ntohs(hdr.size));
+ fprintf(stderr, "write-error 1: %s, written %d/%d\n", strerror(errno), r, ntohs(hdr.size));
shutdown(fd_tun, SHUT_RD);
shutdown(1, SHUT_WR);
rea = 0;
}
fprintf(stderr, "Quitting!\n");
+ close(fd_tun);
+
return 0;
}