From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11987 invoked from network); 22 Jun 2023 19:39:47 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 22 Jun 2023 19:39:47 -0000 Received: (qmail 32290 invoked by uid 89); 22 Jun 2023 19:40:12 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 32283 invoked from network); 22 Jun 2023 19:40:12 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687462784; x=1690054784; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:date:from:from:to:cc:subject :date:message-id:reply-to; bh=dzlu+HfYwi50fgJUwnGjvN8Kduz6xFA8lQOFzz5ycF4=; b=YD47IvIKAcBJsQ6W+170rOSAvbbNHxrO1g8biMToU7DirVDFuOW+Qml2obc09C1GFi ZQV04wiKt1rERc0lkhppLBHJJzj/3XBl/lZ0BrI/lVHzexlBWMmPkPf9aH2cmXq5yir5 B1UzobDPoP9LtfAC2Jt4o+Kf66e0ucfeeFwdZsDFIk4q+UcJjAnrJpp8Y7Pzr3ZW2E8b CXX9lIZZtm4kAYpzrSkQ5M9UkeYRuym3+bCedcScgvVMfNmOBJneurauCyXKco1ghT6q Pw2fuHG1rgXwD9iQN8qooCiTMfv1FT3OrHtEtRI4eH65i/eApwieLcdPLc3p94O1OBRl nIwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687462784; x=1690054784; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:to:date:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dzlu+HfYwi50fgJUwnGjvN8Kduz6xFA8lQOFzz5ycF4=; b=T1v2m5q4IRHy4PdfirnGXUTZDjaBeCCDnM4SIlxnT6kGSr7UHUo2SHbGW4hfE+0kzI RI6vG9HrrzedZOgO/RWiZtti8zb7nUzM5ZizdBcjXWbv9pTLsHPCX18jht7HNlS9vedb VcWKsaUMf5mtBzSd3e9v0A/MjUwQlc7xjJLePEjmqi6kVoCH1oj2TYOj3bBDNV1nr8b8 wDB/6nMphIjgLnsU1HiE8Uv88fO3nNu6qpb5exZ42o7rkTxoangr1ea/au5SIz//ZiPt 2N6sQ/Ek+E55MRkhf7P54pxDz5E/2QTWI7LfnxB+W4Vu3GWvcsOOm/JRzeVlxrMyBLhN TycQ== X-Gm-Message-State: AC+VfDzYY8H1/zP506pwKc2idXt5koKXJ7FaI/stI16z4ehn+QQyWOFI m5tHvWtBAmNrSREQhQkQBlcc3NRVRGc= X-Google-Smtp-Source: ACHHUZ4c13XugvRfOmUiC4up+mRFNPuWLEutwxI4eO14a6SMDvu/z+KThELA1UVZDN3ms+jYSZiW0A== X-Received: by 2002:a05:6808:2198:b0:3a0:596d:6a5f with SMTP id be24-20020a056808219800b003a0596d6a5fmr4785406oib.45.1687462783583; Thu, 22 Jun 2023 12:39:43 -0700 (PDT) From: "Casper Ti. Vector" X-Google-Original-From: "Casper Ti. Vector" Date: Fri, 23 Jun 2023 03:39:39 +0800 To: supervision@list.skarnet.org Subject: Re: A program that can get exactly the log of a supervised process? Message-ID: Mail-Followup-To: supervision@list.skarnet.org References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Fri, Jun 23, 2023 at 01:44:19AM +0800, Casper Ti. Vector wrote: > The source code of the program, logtee (licence: CC0), is available at: > Sorry, patch (the first hunk is cosmetic): --- logtee.c 2023-06-23 03:33:57.233531347 +0800 +++ logtee.c 2023-06-23 03:33:05.693672295 +0800 @@ -29,7 +29,7 @@ *len = 0; return 1; } if (iopause_g (x, 2 - !x[1].fd, 0) < 0) strerr_diefu1sys (111, "iopause_g"); - for (i = 0; i < 2; ++i) if (x[i].fd && x[i].revents) { + for (i = 0; i < 2; ++i) if (x[i].fd > 0 && x[i].revents) { r = fd_write (x[i].fd, buf + pos[i], *len - pos[i]); if (r < 0) { if (!i) return 0; @@ -57,8 +57,9 @@ int main (int argc, char const **argv, char const *const *envp) { int pir[2], fdc, fdw, argc1; PROG = "logtee"; ++argv; --argc; - if ((argc1 = el_semicolon (argv)) >= argc) - { strerr_dief1x (100, "unterminated block"); } + argc1 = el_semicolon (argv); + if (argc1 >= argc) strerr_dief1x (100, "unterminated block"); + if (!argv[0] || !argv[argc1 + 1]) strerr_dief1x (100, "empty program"); argv[argc1] = 0; if (pipe (pir) < 0) strerr_diefu1sys (111, "pipe"); if ((fdc = selfpipe_init ()) < 0) strerr_diefu1sys (111, "selfpipe_init"); -- My current OpenPGP key: RSA4096/0x227E8CAAB7AA186C (expires: 2024.09.30) 7077 7781 B859 5166 AE07 0286 227E 8CAA B7AA 186C