File tree Expand file tree Collapse file tree 4 files changed +25
-2
lines changed
Expand file tree Collapse file tree 4 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ extern unsigned int current_view;
4343#define view_is_displayed (view ) \
4444 (view == display[0] || view == display[1])
4545
46+ void init_tty (void );
4647void init_display (void );
4748void resize_display (void );
4849void redraw_display (bool clear );
Original file line number Diff line number Diff line change @@ -584,7 +584,7 @@ set_terminal_modes(void)
584584 leaveok (stdscr , false);
585585}
586586
587- static void
587+ void
588588init_tty (void )
589589{
590590 /* open */
@@ -598,6 +598,12 @@ init_tty(void)
598598 if (!opt_tty .attr )
599599 die ("Failed allocation for tty attributes" );
600600 tcgetattr (opt_tty .fd , opt_tty .attr );
601+
602+ /* process-group leader */
603+ signal (SIGTTOU , SIG_IGN );
604+ setpgid (getpid (), getpid ());
605+ tcsetpgrp (opt_tty .fd , getpid ());
606+ signal (SIGTTOU , SIG_DFL );
601607}
602608
603609void
@@ -607,7 +613,8 @@ init_display(void)
607613 const char * term ;
608614 int x , y ;
609615
610- init_tty ();
616+ if (!opt_tty .file )
617+ die ("Can't initialize display without tty" );
611618
612619 die_callback = done_display ;
613620 if (atexit (done_display ))
Original file line number Diff line number Diff line change @@ -738,6 +738,14 @@ die_if_failed(enum status_code code, const char *msg)
738738 die ("%s: %s" , msg , get_status_message (code ));
739739}
740740
741+ void
742+ hangup_children (void )
743+ {
744+ if (signal (SIGHUP , SIG_IGN ) == SIG_ERR )
745+ return ;
746+ killpg (getpid (), SIGHUP );
747+ }
748+
741749static inline enum status_code
742750handle_git_prefix (void )
743751{
@@ -772,6 +780,10 @@ main(int argc, const char *argv[])
772780 enum request request = parse_options (argc , argv , pager_mode );
773781 struct view * view ;
774782
783+ init_tty ();
784+
785+ atexit (hangup_children );
786+
775787 if (signal (SIGPIPE , SIG_IGN ) == SIG_ERR )
776788 die ("Failed to setup signal handler" );
777789
Original file line number Diff line number Diff line change @@ -11,6 +11,9 @@ test scripts as long as `PATH` is set to include the directories `src/`
1111and `test/tools` . The latter directory is where the test helper
1212libraries are located, the most important of which is `libtest.sh` .
1313
14+ The test suite requires `stty -tostop` to be set in the running terminal,
15+ which is typically the default.
16+
1417Options
1518-------
1619
You can’t perform that action at this time.
0 commit comments