Hi Klemens,

Klemens Nanni wrote on Thu, Oct 28, 2021 at 11:19:30PM +0000:
> On Fri, Oct 29, 2021 at 12:57:54AM +0200, Ingo Schwarze wrote:

>>   MANPAGER=firefox man -T html $(ifconfig -C)

> This doesn't work if firefox is already running

It is true that it sometimes works and sometimes fails due to a race
condition caused by firefox, but that is kind of orthogonal to benno@'s
question.

> as the MANPAGER firefox process exits immediately after sending the
> file/link to the running process,

I consider that a bug in firefox.  If a program is instructed to open a
file, and in particular a file in /tmp/, it must not exit before actually
opening the file.

> which causes mandoc to exit after removing the temporary file,
> by which time firefox fails to open the no longer exiting file.

Is there a way how man(1) could work around that braindead behaviour
of firefox?  I don't want to commit the following patch - which delays
program exit of man(1) after the pager exits - because the delay is
annoying when using a reasonable pager like less(1).

If someone can come up with an acceptable idea for a workaround,
or if someone can fix firefox, that will be welcome...

Yours,
  Ingo



Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/main.c,v
retrieving revision 1.262
diff -u -p -r1.262 main.c
--- main.c      4 Oct 2021 21:28:50 -0000       1.262
+++ main.c      29 Oct 2021 00:06:24 -0000
@@ -1203,6 +1203,7 @@ woptions(char *arg, enum mandoc_os *os_e
 static void
 run_pager(struct outstate *outst, char *tag_target)
 {
+       const struct timespec delay = { 1, 0 };
        int      signum, status;
        pid_t    man_pgid, tc_pgid;
        pid_t    pager_pid, wait_pid;
@@ -1252,6 +1253,7 @@ run_pager(struct outstate *outst, char *
 
                signum = WSTOPSIG(status);
        }
+       nanosleep(&delay, NULL);
 }
 
 static pid_t

Reply via email to