History

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.

Ganesh Ajjanagadde committed 11 years ago

Commit 92b1a0f1 parent 5edf8b11 file · +5 −5Browse files

Unified · Split

ffserver.c+5−5
@@ -1936,7 +1936,7 @@ static void compute_status(HTTPContext *c) · 1935 unmodified lines
19361936
19371937 avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
19381938 if (stream->pid) {
1939− avio_printf(pb, "Running as pid %d.\n", stream->pid);
1939+ avio_printf(pb, "Running as pid %"PRId64".\n", (int64_t) stream->pid);
19401940
19411941 #if defined(linux)
19421942 {
@@ -1945,8 +1945,8 @@ static void compute_status(HTTPContext *c) · 2 unmodified lines
19451945
19461946 /* This is somewhat linux specific I guess */
19471947 snprintf(ps_cmd, sizeof(ps_cmd),
1948− "ps -o \"%%cpu,cputime\" --no-headers %d",
1949− stream->pid);
1948+ "ps -o \"%%cpu,cputime\" --no-headers %"PRId64"",
1949+ (int64_t) stream->pid);
19501950
19511951 pid_stat = popen(ps_cmd, "r");
19521952 if (pid_stat) {
@@ -3778,8 +3778,8 @@ static void handle_child_exit(int sig) · 1825 unmodified lines
37783778 uptime = time(0) - feed->pid_start;
37793779 feed->pid = 0;
37803780 fprintf(stderr,
3781− "%s: Pid %d exited with status %d after %d seconds\n",
3782− feed->filename, pid, status, uptime);
3781+ "%s: Pid %"PRId64" exited with status %d after %d seconds\n",
3782+ feed->filename, (int64_t) pid, status, uptime);
37833783
37843784 if (uptime < 30)
37853785 /* Turn off any more restarts */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t