From: Lennart Poettering Date: Sun, 21 Nov 2004 00:04:17 +0000 (+0000) Subject: * some minor pid file fixes X-Git-Tag: submit/2.0-panda/20130828.192557~4210 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6985eda9347730d4506de630c310a34e7844df0a;p=profile%2Fivi%2Fpulseaudio-panda.git * some minor pid file fixes git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@297 fefdeb5f-60dc-0310-8127-8f9354f1896f --- diff --git a/polyp/pid.c b/polyp/pid.c index 142c4f6..a52bed0 100644 --- a/polyp/pid.c +++ b/polyp/pid.c @@ -90,9 +90,12 @@ int pa_pid_file_create(void) { pa_log(__FILE__": stale PID file, overwriting.\n"); } - lseek(fd, 0, SEEK_SET); + if (lseek(fd, 0, SEEK_SET) == (off_t) -1 || ftruncate(fd, 0) < 0) { + pa_log(__FILE__": failed to truncate PID fil: %s.\n", strerror(errno)); + goto fail; + } - snprintf(t, sizeof(t), "%lu", (unsigned long) getpid()); + snprintf(t, sizeof(t), "%lu\n", (unsigned long) getpid()); l = strlen(t); if (pa_loop_write(fd, t, l) != (ssize_t) l) {