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:
@@ -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