Commit 92b1a0fa authored by Ganesh Ajjanagadde's avatar Ganesh Ajjanagadde Committed by Michael Niedermayer

ffserver: cast PID to int64_t before printing

Unfortunately, there is no portable format specifier for PID's.
Furthermore, it is not safe to assume pid_t <= 32 bit in size,
see e.g http://unix.derkeiler.com/Mailing-Lists/AIX-L/2010-08/msg00008.html.
Right now, it is ok to assume pid_t <= 32 bit in size, but this may change in the future.
Also, this patch fixes warning due to lack of an appropriate cast from
http://fate.ffmpeg.org/report.cgi?time=20150820233505&slot=x86-opensolaris-gcc4.3.
Note that this method of handling pid_t is in line with what nginx does.
Signed-off-by: 's avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 5edf8b11
...@@ -1936,7 +1936,7 @@ static void compute_status(HTTPContext *c) ...@@ -1936,7 +1936,7 @@ static void compute_status(HTTPContext *c)
avio_printf(pb, "<h2>Feed %s</h2>", stream->filename); avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
if (stream->pid) { if (stream->pid) {
avio_printf(pb, "Running as pid %d.\n", stream->pid); avio_printf(pb, "Running as pid %"PRId64".\n", (int64_t) stream->pid);
#if defined(linux) #if defined(linux)
{ {
...@@ -1945,8 +1945,8 @@ static void compute_status(HTTPContext *c) ...@@ -1945,8 +1945,8 @@ static void compute_status(HTTPContext *c)
/* This is somewhat linux specific I guess */ /* This is somewhat linux specific I guess */
snprintf(ps_cmd, sizeof(ps_cmd), snprintf(ps_cmd, sizeof(ps_cmd),
"ps -o \"%%cpu,cputime\" --no-headers %d", "ps -o \"%%cpu,cputime\" --no-headers %"PRId64"",
stream->pid); (int64_t) stream->pid);
pid_stat = popen(ps_cmd, "r"); pid_stat = popen(ps_cmd, "r");
if (pid_stat) { if (pid_stat) {
...@@ -3778,8 +3778,8 @@ static void handle_child_exit(int sig) ...@@ -3778,8 +3778,8 @@ static void handle_child_exit(int sig)
uptime = time(0) - feed->pid_start; uptime = time(0) - feed->pid_start;
feed->pid = 0; feed->pid = 0;
fprintf(stderr, fprintf(stderr,
"%s: Pid %d exited with status %d after %d seconds\n", "%s: Pid %"PRId64" exited with status %d after %d seconds\n",
feed->filename, pid, status, uptime); feed->filename, (int64_t) pid, status, uptime);
if (uptime < 30) if (uptime < 30)
/* Turn off any more restarts */ /* Turn off any more restarts */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment