On Sat, Jul 25, 2015 at 5:16 AM, wm4 <nfx...@googlemail.com> wrote:
> On Sat, 25 Jul 2015 00:20:01 -0400
> Ganesh Ajjanagadde <gajjanaga...@gmail.com> wrote:
>
>> This makes code slightly more robust and fixes a -Wunused-result
>>
>> Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com>
>> ---
>>  ffmpeg.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/ffmpeg.c b/ffmpeg.c
>> index 751c7d3..aab53e8 100644
>> --- a/ffmpeg.c
>> +++ b/ffmpeg.c
>> @@ -322,13 +322,15 @@ static int main_return_code = 0;
>>  static void
>>  sigterm_handler(int sig)
>>  {
>> +    ssize_t num_write;
>>      received_sigterm = sig;
>>      received_nb_signals++;
>>      term_exit_sigsafe();
>>      if(received_nb_signals > 3) {
>> -        write(2/*STDERR_FILENO*/, "Received > 3 system signals, hard 
>> exiting\n",
>> +        num_write = write(2/*STDERR_FILENO*/, "Received > 3 system signals, 
>> hard exiting\n",
>>                             strlen("Received > 3 system signals, hard 
>> exiting\n"));
>> -
>> +        if(num_write < 0)
>> +            perror("write");
>>          exit(123);
>>      }
>>  }
>
> perror isn't async signal safe, so this makes the code less correct.

Ok. How about making this errno set by write (if any) become part of
the exit code, e.g by or'ing?
As it stands, the 123 in the exit status sounds quite arbitrary, so
this should be ok,
and gives the parent a chance to distinguish between the two cases.

> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to