From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS6130 216.105.38.0/24 X-Spam-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 7071B1F4D7 for ; Sun, 5 Jun 2022 21:25:57 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sourceforge.net header.i=@sourceforge.net header.b="E0ChgBjt"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sf.net header.i=@sf.net header.b="JkTjqbcT"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=yhbt.net header.i=@yhbt.net header.b="a0fNXe1H"; dkim-atps=neutral Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1nxxkq-00032t-33; Sun, 05 Jun 2022 21:25:48 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nxxko-00032n-VV for sox-devel@lists.sourceforge.net; Sun, 05 Jun 2022 21:25:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7ll7I4HV8QCv0Pni4PjALjIopoKpo9M9HpxOwZYvYAk=; b=E0ChgBjt4EPem6REN79h3c51j/ XBUhe/pC4UWBJAgmJ2zjpkIsVsYG044IcclFR4sH1JoFa6ly9CD/pWarW2GQG0Xvcptl8JcA+vHCD K5+NTI72yQ0CWtxCwaKG2aS+/WMWdRtU95auYn5w2QjLGVAmue3DQfd3ZjwNq5X4+kCE=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Subject:To:From:Date:Sender:Reply-To :Cc:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=7ll7I4HV8QCv0Pni4PjALjIopoKpo9M9HpxOwZYvYAk=; b=J kTjqbcTlHNV92xO9akA1QeUx60nR9BZFtZJ3SQ4TmzDLcFYOwiCMAQRHmnVAXjuEQhoQJwZ4m6xyU 4V7PC2kBBc2Gzij8sH2Oxzk2n4i3G+JxsNj3lIIxnxqbj/P3DdfI4JEEfhT16hhwMxR12bn7/GgN9 M+hkz7ZmcDV4mRko=; Received: from dcvr.yhbt.net ([64.71.152.64]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.94.2) id 1nxxkk-0000cH-T4 for sox-devel@lists.sourceforge.net; Sun, 05 Jun 2022 21:25:47 +0000 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C0A941F4D7; Sun, 5 Jun 2022 21:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yhbt.net; s=selector1; t=1654463247; bh=sHoVfOZ1EQ7EcpFcmJTSkG1YimRauT18xFURWSRzZ44=; h=Date:From:To:Subject:From; b=a0fNXe1Hl5tLigYkqBam0tlXdbw9/HvkTuSmxl0FIl0412L1dKMvYwA1wHnU4A89L 4SHG9WN0BDjVGajyfZ7HePZ2rARVcUX/oNmZdAfuNsmtZsHkMxntpyAoZ87Qsm3T/z sxTIf8yjAOXp7+1d/wZJVgt7Y8znubDreWTxoo7I= Date: Sun, 5 Jun 2022 21:07:27 +0000 From: Eric Wong To: sox-devel@lists.sourceforge.net Message-ID: <20220605210727.GA9582@dcvr> MIME-Version: 1.0 Content-Disposition: inline X-Headers-End: 1nxxkk-0000cH-T4 Subject: [WIP/PATCH] restart writes on EINTR X-BeenThere: sox-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: sox-devel-bounces@lists.sourceforge.net Only compile-tested, and I gotta run out for a bit and my not return alive. I just noticed some EINTR errors while writing to pipes and haven't dealt with stdio or C in ages at this point. diff --git a/src/formats_i.c b/src/formats_i.c index 7048040d..d4082cc5 100644 --- a/src/formats_i.c +++ b/src/formats_i.c @@ -129,10 +129,21 @@ int lsx_padbytes(sox_format_t * ft, size_t n) */ size_t lsx_writebuf(sox_format_t * ft, void const * buf, size_t len) { - size_t ret = fwrite(buf, (size_t) 1, len, (FILE*)ft->fp); - if (ret != len) { - lsx_fail_errno(ft, errno, "error writing output file"); - clearerr((FILE*)ft->fp); /* Allows us to seek back to write header */ + FILE *fp = (FILE*)ft->fp; + const char *c = (const char *)buf; + size_t ret = fwrite(c, 1, len, fp); + + while (ret != len) { + switch (errno) { + case EINTR: + len -= ret; + c += ret; + ret = fwrite(c, 1, len, fp); + break; + default: + lsx_fail_errno(ft, errno, "error writing output file"); + clearerr(fp); /* Allows us to seek back to write header */ + } } ft->tell_off += ret; return ret; _______________________________________________ SoX-devel mailing list SoX-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-devel