Re: A program that can get exactly the log of a supervised process?

From: Casper Ti. Vector <caspervector_at_gmail.com>
Date: Fri, 23 Jun 2023 03:39:39 +0800

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
_at__at_ -29,7 +29,7 _at__at_
     *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;
_at__at_ -57,8 +57,9 _at__at_
 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
Received on Thu Jun 22 2023 - 21:39:39 CEST

This archive was generated by hypermail 2.4.0 : Thu Jun 22 2023 - 21:40:14 CEST