|
|
| version 1.6, 2011/06/07 11:49:39 | version 1.7, 2011/10/31 13:53:51 |
|---|---|
| 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; | |
| } |