if (!(f=fopen(pidfile,"r")))
return 0;
- fscanf(f,"%ld", &pid);
+ if(fscanf(f,"%ld", &pid) != 1)
+ pid = 0;
fclose(f);
return pid;
}
pid_t pid;
if ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1) {
- close(fd);
return 0;
}
if ((f = fdopen(fd, "r+")) == NULL) {
- fclose(f);
+ close(fd);
return 0;
}