]> code.delx.au - pulseaudio/blobdiff - polyp/pid.c
cleanup zeroconf service names
[pulseaudio] / polyp / pid.c
index 232de216e777465478bb8b4efe805a1eb2528202..2fac687ec876685064be879f18657a00ff905531 100644 (file)
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <errno.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
@@ -42,8 +43,8 @@
  * pid could be read, return 0, on failure (pid_t) -1 */
 static pid_t read_pid(const char *fn, int fd) {
     ssize_t r;
-    char t[20], *e = NULL;
-    long int pid;
+    char t[20], *e;
+    uint32_t pid;
 
     assert(fn && fd >= 0);
 
@@ -56,8 +57,10 @@ static pid_t read_pid(const char *fn, int fd) {
         return (pid_t) 0;
     
     t[r] = 0;
+    if ((e = strchr(t, '\n')))
+        *e = 0;
 
-    if (!t[0] || (pid = strtol(t, &e, 0)) == 0 || (*e != 0 && *e != '\n')) {
+    if (pa_atou(t, &pid) < 0) {
         pa_log(__FILE__": WARNING: failed to parse PID file '%s'\n", fn);
         return (pid_t) -1;
     }