From patchwork Thu Jan 18 23:42:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 7341 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.156.27 with SMTP id q27csp137854jak; Thu, 18 Jan 2018 15:42:57 -0800 (PST) X-Google-Smtp-Source: ACJfBovuwUGwvAFKru75RRmXyWCdnBONRHMS9+jiyNY9nmuIJxV9igOstTaAlOwoWs6SQsA/sSy5 X-Received: by 10.28.24.11 with SMTP id 11mr2256707wmy.108.1516318977242; Thu, 18 Jan 2018 15:42:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516318977; cv=none; d=google.com; s=arc-20160816; b=etr9MGmOeiEqttHtlcdUJcmtTHpQty3H1h5sNWSqyNgz1cqd9fbA6oK4ZmD3X7NFL6 cSoaP+gkzvWlmg4c+xCh1jAFwD0G++1pVkUXf7mEl7fu7hJZjYbtv7IP6+ztAt+CRCIn bnM+yW1acPUaiKS4J8XKG18whyA8D7gYa0qePBjpxLOYaUAFSdwPOohwf6pMvD7oGSUl J112Ug8eUMG+9SWz+lfjSNbCdsE7BOvuoFqRNa3aftpBuqBRr+8bl4tB/uayGZCvtNS2 ouWvvWAZd4NxVjczwPKEIZchQN0u6iZHsaGZvtgLFlWpTGXFa5KpGi9dcXwuXMhCzX2L MNWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:content-language:in-reply-to:mime-version :user-agent:date:message-id:references:to:from:dkim-signature :delivered-to:arc-authentication-results; bh=G30dzusMioTEoYFqboBtAPsZcoUIHLpwTpN31HotVjQ=; b=fWafhCE2W9fzMaFKIWHXiIg8jMrQb9MwdWLJJll+AbmA2RuL8BZAZlLf8g3bzYljne JSad5yHJlc4Zn+DQCvt2+7/VbMvexEpS/GxdtnP8o5rn5D1iI8mVR5PBnbdP6yXLkeqt F2UtFWFzwCYjkMHckwND4s29Y5rt6WsTjXogvxfFi+q/0q8tGoYy6v1/soHaPBvmfICS 9JbzZDkDMZKRk+MYjnj3jZ2fhtvsom/atQm4Ry3lZ4CnL31LYsQtnI3BPhFntEQ6lMFp b9Og7nwQBJJOv+t1ZCWi08PcCIzQwIRjhsrlTQH3QpVO1cdyhCQP2u/ox5CO66peYDbW F1mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=WEMK/u6U; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s59si1717237wrc.489.2018.01.18.15.42.56; Thu, 18 Jan 2018 15:42:57 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=WEMK/u6U; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C6AE068A2FE; Fri, 19 Jan 2018 01:42:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f52.google.com (mail-wm0-f52.google.com [74.125.82.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3017568A249 for ; Fri, 19 Jan 2018 01:42:48 +0200 (EET) Received: by mail-wm0-f52.google.com with SMTP id v123so161059wmd.5 for ; Thu, 18 Jan 2018 15:42:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=subject:from:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=z+QXXdS+I0ZeN5CpYqa36q28sgdrco6K4eYS2KUyDi8=; b=WEMK/u6U3JFI9EYy5vx3VwidNEZuLYcuNsCdaI1ErZ2Q/+bDxyBhd7tT2E4tKcycjy 2f+XsUguXiZaGS86AiS60Pa94s/aQjXuhO3Ua3rlHsO82eHqj0TnrfzCnR2S1uSIlX5s Gf+o7e7HhXsXAq+7VgckblxaSInwGFAO8lLY+XXDPrWYuu29e6MRz2BI/GO7OlPRFiFj t9rxrNmtfmW+rxfN/l7He2GFlbwKj74OZoJtkzWpfEiaFILTfQBtF7X/ClcymU3NJ477 OU4zxB4Zo681npsHISW7BrFaS9YYdHRwZpKGPaXXU2KNXlgaSW5lViK8CgBLZ/tpu5c3 DOOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=z+QXXdS+I0ZeN5CpYqa36q28sgdrco6K4eYS2KUyDi8=; b=FHF3pk+NXEdc51bL5+DXD+LgJkb3QR1mCPJ0wZPIG/SGRel/RMlZ8XaMfDFentSyLq JMKrM+42ss3BKQtMhmWV8IxD3t3mc8pw8xYFjW1UV6XN5wU083jaAy/cPK9c5ONAUN2p CwfnoTiDzxkqDzAogiF8hOWNK188ksVE0aXj+YMcvKyB340g/bznkMHMjWG65UfYzFUx n1x9tMVTX1OwVQIWqGS7Ff60GoFtndFd/515x4EWOZoRuZT18HmIwH8sHAEHv7tGYMlk +fDjs7Y8jmkQNeZlLK2AMc4lhbCE3MnxozA8AJc4XMXYUunYO7UoZuyoP4q0JF32A1Dd 5mlA== X-Gm-Message-State: AKwxytfFB2HL+50PFiOUsO3DH+8rBNpAfvdkv7in5YgGlgCbwWMTqQD8 koA1eBfu29GKNJTlMBcZxJgUhLa4 X-Received: by 10.28.21.66 with SMTP id 63mr6900410wmv.44.1516318967857; Thu, 18 Jan 2018 15:42:47 -0800 (PST) Received: from [192.168.0.3] (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id p29sm97029wmf.20.2018.01.18.15.42.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Jan 2018 15:42:47 -0800 (PST) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org References: <22E79390-C8BE-487F-A03A-B956C95E3CC8@dericed.com> <20180111214348.GA2196808@phare.normalesup.org> <20180111224532.GJ32530@sunshine.barsnick.net> <20180111225133.GA2224502@phare.normalesup.org> Message-ID: <7dc07c47-d9ba-4db3-4fd0-a5a16bbb6e22@jkqxz.net> Date: Thu, 18 Jan 2018 23:42:46 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Subject: [FFmpeg-devel] [PATCH] ffmpeg: Ignore SIGPIPE X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" On systems which deliver SIGPIPE (Unices), a broken pipe will currently result in the immediate termination of the ffmpeg process (the default disposition as required by POSIX). This is undesirable, because while the broken pipe is likely fatal to useful cleanup of whatever component is writing to it, there might be other components which can do useful cleanup - for example, a muxer on another stream may still need to write indexes to complete a file. Therefore, set the signal disposition for SIGPIPE to ignore the signal - the call which caused the signal will fail with EPIPE and the error will be propagated upwards like any other I/O failure on a single stream. --- On 18/01/18 15:55, Mark Thompson wrote: > On 18/01/18 14:49, Dave Rice wrote: >> Thread bump. >> >>> On Jan 11, 2018, at 5:51 PM, Nicolas George wrote: >>> >>> Moritz Barsnick (2018-01-11): >>>> This patch doesn't change the handling of SIGTERM >>> >>> You should have read SIGPIPE, obviously. >>> >>>> Is SIGPIPE an interactive signal? >>> >>> Of course not. >>> >>>> Anything on the other side of output >>>> file(name) "-" or "pipe:N" may terminate for some reason. >>> >>> Yes, that is exactly what SIGPIPE is for. >>> >>>> This patch does NOT try to ignore anything. ffmpeg won't keep running >>>> due to ignoring of SIGPIPE, it will terminate more cleanly due to >>>> handling it. The former is not desired. (But yes, shall handing to >>>> enforce ignoring it would allow that.) >>> >>> It will terminate less cleanly than if you do the right thing with >>> SIGPIPE. >> >> This patch has been working for me and ffmpeg terminates cleanly with SIGPIPE with a valid output (moov atom written with mov or cues/seekhead written with mkv). Not sure if I understand well the disadvantage of this patch. > > Making SIGPIPE have an effect like this seems highly dubious to me, but I admit that since it always killed the process before it feels like an improvement. > > Changing it to ignore the signal (set it to SIG_IGN) instead sounds like a safer option? I think that would move the code to having the same behaviour on Unices as on Windows, since Windows has no SIGPIPE. To offer this suggestion in a more concrete form. fftools/ffmpeg.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 528849a2c6..918eb353aa 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -406,6 +406,9 @@ void term_init(void) #ifdef SIGXCPU signal(SIGXCPU, sigterm_handler); #endif +#ifdef SIGPIPE + signal(SIGPIPE, SIG_IGN); /* Broken pipe (POSIX). */ +#endif #if HAVE_SETCONSOLECTRLHANDLER SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE); #endif