]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/pid.c
remap: build sse code only on x86
[pulseaudio] / src / pulsecore / pid.c
index 1c0851baeb64c250739bb9a38decd2ad8c581549..008784629de97b899580773aaf42af3568276f93 100644 (file)
@@ -6,7 +6,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as
-  published by the Free Software Foundation; either version 2 of the
+  published by the Free Software Foundation; either version 2.1 of the
   License, or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
   License, or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
@@ -171,14 +171,14 @@ static int proc_name_ours(pid_t pid, const char *procname) {
         good = pa_startswith(stored, expected);
         pa_xfree(expected);
 
         good = pa_startswith(stored, expected);
         pa_xfree(expected);
 
-#if !defined(__OPTIMIZE__)
+/*#if !defined(__OPTIMIZE__)*/
         if (!good) {
             /* libtool likes to rename our binary names ... */
             expected = pa_sprintf_malloc("%lu (lt-%s)", (unsigned long) pid, procname);
             good = pa_startswith(stored, expected);
             pa_xfree(expected);
         }
         if (!good) {
             /* libtool likes to rename our binary names ... */
             expected = pa_sprintf_malloc("%lu (lt-%s)", (unsigned long) pid, procname);
             good = pa_startswith(stored, expected);
             pa_xfree(expected);
         }
-#endif
+/*#endif*/
 
         return !!good;
     }
 
         return !!good;
     }
@@ -211,6 +211,7 @@ int pa_pid_file_create(const char *procname) {
     if ((pid = read_pid(fn, fd)) == (pid_t) -1)
         pa_log_warn("Corrupt PID file, overwriting.");
     else if (pid > 0) {
     if ((pid = read_pid(fn, fd)) == (pid_t) -1)
         pa_log_warn("Corrupt PID file, overwriting.");
     else if (pid > 0) {
+        int ours = 1;
 
 #ifdef OS_IS_WIN32
         if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)) != NULL) {
 
 #ifdef OS_IS_WIN32
         if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)) != NULL) {
@@ -218,11 +219,13 @@ int pa_pid_file_create(const char *procname) {
 #else
         if (kill(pid, 0) >= 0 || errno != ESRCH) {
 #endif
 #else
         if (kill(pid, 0) >= 0 || errno != ESRCH) {
 #endif
-            int ours = 1;
 
             if (procname)
 
             if (procname)
-                if ((ours = proc_name_ours(pid, procname)) < 0)
+                if ((ours = proc_name_ours(pid, procname)) < 0) {
+                    pa_log_warn("Could not check to see if pid %lu is a pulseaudio process. "
+                                "Asssuming it is and the daemon is already running.", (unsigned long) pid);
                     goto fail;
                     goto fail;
+                }
 
             if (ours) {
                 pa_log("Daemon already running.");
 
             if (ours) {
                 pa_log("Daemon already running.");
@@ -235,7 +238,7 @@ int pa_pid_file_create(const char *procname) {
     }
 
     /* Overwrite the current PID file */
     }
 
     /* Overwrite the current PID file */
-    if (lseek(fd, 0, SEEK_SET) == (off_t) -1 || ftruncate(fd, 0) < 0) {
+    if (lseek(fd, (off_t) 0, SEEK_SET) == (off_t) -1 || ftruncate(fd, (off_t) 0) < 0) {
         pa_log("Failed to truncate PID file '%s': %s", fn, pa_cstrerror(errno));
         goto fail;
     }
         pa_log("Failed to truncate PID file '%s': %s", fn, pa_cstrerror(errno));
         goto fail;
     }
@@ -288,7 +291,7 @@ int pa_pid_file_remove(void) {
         goto fail;
     }
 
         goto fail;
     }
 
-    if (ftruncate(fd, 0) < 0) {
+    if (ftruncate(fd, (off_t) 0) < 0) {
         pa_log_warn("Failed to truncate PID file '%s': %s", fn, pa_cstrerror(errno));
         goto fail;
     }
         pa_log_warn("Failed to truncate PID file '%s': %s", fn, pa_cstrerror(errno));
         goto fail;
     }