… | |
… | |
91 | int fd; |
91 | int fd; |
92 | int pid; |
92 | int pid; |
93 | |
93 | |
94 | if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1) |
94 | if ( ((fd = open(pidfile, O_RDWR|O_CREAT, 0644)) == -1) |
95 | || ((f = fdopen(fd, "r+")) == NULL) ) { |
95 | || ((f = fdopen(fd, "r+")) == NULL) ) { |
96 | fprintf(stderr, "Can't open or create %s.\n", pidfile); |
96 | fprintf(stderr, "Can't open or create %s.\n", pidfile ? pidfile : "(null)"); |
97 | return 0; |
97 | return 0; |
98 | } |
98 | } |
99 | |
99 | |
100 | #ifdef HAVE_FLOCK |
100 | #ifdef HAVE_FLOCK |
101 | if (flock(fd, LOCK_EX|LOCK_NB) == -1) { |
101 | if (flock(fd, LOCK_EX|LOCK_NB) == -1) { |