exit(EXIT_SUCCESS);
}
- pid = setsid();
+ setsid();
freopen("/dev/null", "r", stdin);
freopen("/dev/null", "w", stdout);
if (ret != -1) {
ret = listen(fd, 5);
+ if (ret == -1) {
+ close(fd);
+ fd = -1;
+ }
}
-
+
return fd;
}
while ((optchar = getopt(argc, argv, "c:fh")) != -1 ) {
switch (optchar) {
case 'c':
+ if (configfile != NULL) {
+ free(configfile);
+ }
configfile = strdup(optarg);
break;
case 'f':