version 1.5.4.1, 2011/05/10 20:47:31
|
version 1.6.4.1, 2011/10/04 14:33:32
|
Line 558 ioWatchDirLoop(const char *csDir, int (*callback)(cons
|
Line 558 ioWatchDirLoop(const char *csDir, int (*callback)(cons
|
close(kq); |
close(kq); |
return n; |
return n; |
} |
} |
|
|
|
/* |
|
* ioCreatePIDFile() Create PID file |
|
* @csName = PID filename |
|
* @ifExists = !=0 if filename exists return error |
|
* return: -1 error or 0 ok |
|
*/ |
|
inline int |
|
ioCreatePIDFile(const char *csName, int ifExists) |
|
{ |
|
int fd; |
|
char str[STRSIZ] = { 0 }; |
|
|
|
if (!csName) |
|
return -1; |
|
|
|
fd = open(csName, O_WRONLY | O_CREAT | (ifExists ? O_EXCL : 0), 0644); |
|
if (fd == -1) { |
|
LOGERR; |
|
return -1; |
|
} |
|
snprintf(str, sizeof str, "%d", getpid()); |
|
write(fd, str, strlen(str)); |
|
close(fd); |
|
return 0; |
|
} |