Cast pid_t to long for fprintf()
pid_t is defined by POSIX to be a signed integer type, so the %u format is wrong. Cast to long and print with %ld - it is unlikely that any real-world system has pid_t bigger than long.
This commit is contained in:
@@ -1425,7 +1425,7 @@ FILE *t;
|
||||
void setup_pid(void)
|
||||
{
|
||||
#ifdef WANT_DETACH
|
||||
pid_t pid;
|
||||
pid_t pid;
|
||||
if (!do_check_pid)
|
||||
return;
|
||||
if ((pid = getpid()))
|
||||
@@ -1434,7 +1434,7 @@ pid_t pid;
|
||||
unlink(pidfile);
|
||||
if ((t = fopen(pidfile, "w")))
|
||||
{
|
||||
fprintf(t, "%u\n", pid);
|
||||
fprintf(t, "%ld\n", (long)pid);
|
||||
fclose(t);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user