* mdocml: Use stdout rather than stdin for controlling the terminal such
@ 2017-01-09 17:50 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-01-09 17:50 UTC (permalink / raw)
To: source
Log Message:
-----------
Use stdout rather than stdin for controlling the terminal
such that "cat foo.mdoc | man -l" works.
Issue reported by Christian Neukirchen <chneukirchen at gmail dot com>
and also tested by him on Void Linux with both glibc and musl.
The patch makes sense to millert@.
Modified Files:
--------------
mdocml:
main.c
tag.c
Revision Data
-------------
Index: main.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/main.c,v
retrieving revision 1.278
retrieving revision 1.279
diff -Lmain.c -Lmain.c -u -p -r1.278 -r1.279
--- main.c
+++ main.c
@@ -531,10 +531,10 @@ out:
/* Stop here until moved to the foreground. */
- tc_pgid = tcgetpgrp(STDIN_FILENO);
+ tc_pgid = tcgetpgrp(tag_files->ofd);
if (tc_pgid != man_pgid) {
if (tc_pgid == pager_pid) {
- (void)tcsetpgrp(STDIN_FILENO,
+ (void)tcsetpgrp(tag_files->ofd,
man_pgid);
if (signum == SIGTTIN)
continue;
@@ -547,7 +547,7 @@ out:
/* Once in the foreground, activate the pager. */
if (pager_pid) {
- (void)tcsetpgrp(STDIN_FILENO, pager_pid);
+ (void)tcsetpgrp(tag_files->ofd, pager_pid);
kill(pager_pid, SIGCONT);
} else
pager_pid = spawn_pager(tag_files);
@@ -1076,7 +1076,7 @@ spawn_pager(struct tag_files *tag_files)
break;
default:
(void)setpgid(pager_pid, 0);
- (void)tcsetpgrp(STDIN_FILENO, pager_pid);
+ (void)tcsetpgrp(tag_files->ofd, pager_pid);
#if HAVE_PLEDGE
if (pledge("stdio rpath tmppath tty proc", NULL) == -1)
err((int)MANDOCLEVEL_SYSERR, "pledge");
@@ -1094,7 +1094,7 @@ spawn_pager(struct tag_files *tag_files)
/* Do not start the pager before controlling the terminal. */
- while (tcgetpgrp(STDIN_FILENO) != getpid())
+ while (tcgetpgrp(STDOUT_FILENO) != getpid())
nanosleep(&timeout, NULL);
execvp(argv[0], argv);
Index: tag.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/tag.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -Ltag.c -Ltag.c -u -p -r1.16 -r1.17
--- tag.c
+++ tag.c
@@ -221,11 +221,11 @@ tag_unlink(void)
pid_t tc_pgid;
if (tag_files.tcpgid != -1) {
- tc_pgid = tcgetpgrp(STDIN_FILENO);
+ tc_pgid = tcgetpgrp(tag_files.ofd);
if (tc_pgid == tag_files.pager_pid ||
tc_pgid == getpgid(0) ||
getpgid(tc_pgid) == -1)
- (void)tcsetpgrp(STDIN_FILENO, tag_files.tcpgid);
+ (void)tcsetpgrp(tag_files.ofd, tag_files.tcpgid);
}
if (*tag_files.ofn != '\0')
unlink(tag_files.ofn);
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-01-09 17:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 17:50 mdocml: Use stdout rather than stdin for controlling the terminal such schwarze
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).