[FFmpeg-devel] [PATCH 11/13] ffserver: log diagnostics for popen return failure

Ganesh Ajjanagadde gajjanagadde at gmail.com
Tue Jan 12 05:25:13 CET 2016


Some errno hackery needed since errno is not set for when popen fails
due to out of memory; man popen.

Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
---
 ffserver.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/ffserver.c b/ffserver.c
index 51928f3..4cd5834 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -2072,6 +2072,8 @@ static void compute_status(HTTPContext *c)
                          "ps -o \"%%cpu,cputime\" --no-headers %"PRId64"",
                          (int64_t) stream->pid);
 
+                 /* reset errno before trying popen */
+                 errno = 0;
                  pid_stat = popen(ps_cmd, "r");
                  if (pid_stat) {
                      char cpuperc[10];
@@ -2087,6 +2089,15 @@ static void compute_status(HTTPContext *c)
                                "Unable to close pid stat '%s': %s\n",
                                ps_cmd, av_err2str(AVERROR(errno)));
                  }
+                 else if (errno)
+                     av_log(NULL, AV_LOG_WARNING,
+                            "Unable to open pid stat '%s': %s\n",
+                            ps_cmd, av_err2str(AVERROR(errno)));
+                 else
+                     av_log(NULL, AV_LOG_WARNING,
+                            "Unable to open pid stat '%s': %s\n",
+                            ps_cmd, av_err2str(AVERROR(ENOMEM)));
+
             }
 #endif
 
-- 
2.7.0



More information about the ffmpeg-devel mailing list