From: "Casper Ti. Vector" <caspervector@gmail.com>
To: supervision@list.skarnet.org
Subject: Re: A program that can get exactly the log of a supervised process?
Date: Fri, 23 Jun 2023 03:39:39 +0800 [thread overview]
Message-ID: <ZJSjezfU8Kkiin/2@CasperVector> (raw)
In-Reply-To: <ZJSIcyVLUE2SLg6u@CasperVector>
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:
> <https://cpaste.org/?fa30831511a456b7=#ECwUd1YaVQBLUokynQbRYZq5wvBvXXeXo3bQoeL2rL4L>
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
next prev parent reply other threads:[~2023-06-22 19:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-23 16:03 Casper Ti. Vector
2023-06-22 17:44 ` Casper Ti. Vector
2023-06-22 19:39 ` Casper Ti. Vector [this message]
2023-06-22 19:43 ` Casper Ti. Vector
[not found] <YXQyNQbpPZBKYLXC@caspervector>
2021-10-24 6:20 ` Laurent Bercot
2021-10-24 7:20 ` Casper Ti. Vector
[not found] ` <YXUJKWltk+OwYhtf@caspervector>
2021-10-25 12:37 ` Laurent Bercot
2021-10-25 12:57 ` Rio Liu
2021-10-25 13:26 ` Laurent Bercot
2021-10-25 16:00 ` Casper Ti. Vector
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZJSjezfU8Kkiin/2@CasperVector \
--to=caspervector@gmail.com \
--cc=supervision@list.skarnet.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).