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:
Kevin Easton
2017-02-17 16:50:41 +11:00
parent 686344314f
commit a0e8bd5742

View File

@@ -1434,7 +1434,7 @@ pid_t pid;
unlink(pidfile); unlink(pidfile);
if ((t = fopen(pidfile, "w"))) if ((t = fopen(pidfile, "w")))
{ {
fprintf(t, "%u\n", pid); fprintf(t, "%ld\n", (long)pid);
fclose(t); fclose(t);
} }
} }