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
1936 1936
1937 avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);1937 avio_printf(pb, "<h2>Feed %s</h2>", stream->filename);
1938 if (stream->pid) {1938 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);
1940 1940
1941#if defined(linux)1941#if defined(linux)
1942 {1942 {
@@ -1945,8 +1945,8 @@ static void compute_status(HTTPContext *c) · 2 unmodified lines
1945 1945
1946 /* This is somewhat linux specific I guess */1946 /* This is somewhat linux specific I guess */
1947 snprintf(ps_cmd, sizeof(ps_cmd),1947 snprintf(ps_cmd, sizeof(ps_cmd),
1948 "ps -o \"%%cpu,cputime\" --no-headers %d",1948 "ps -o \"%%cpu,cputime\" --no-headers %"PRId64"",
1949 stream->pid);1949 (int64_t) stream->pid);
1950 1950
1951 pid_stat = popen(ps_cmd, "r");1951 pid_stat = popen(ps_cmd, "r");
1952 if (pid_stat) {1952 if (pid_stat) {
@@ -3778,8 +3778,8 @@ static void handle_child_exit(int sig) · 1825 unmodified lines
3778 uptime = time(0) - feed->pid_start;3778 uptime = time(0) - feed->pid_start;
3779 feed->pid = 0;3779 feed->pid = 0;
3780 fprintf(stderr,3780 fprintf(stderr,
3781 "%s: Pid %d exited with status %d after %d seconds\n",3781 "%s: Pid %"PRId64" exited with status %d after %d seconds\n",
3782 feed->filename, pid, status, uptime);3782 feed->filename, (int64_t) pid, status, uptime);
3783 3783
3784 if (uptime < 30)3784 if (uptime < 30)
3785 /* Turn off any more restarts */3785 /* 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