1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-09-27 02:56:18 -04:00

[fg] Try to send CONT signal only from the master instance. Refs #287

This commit is contained in:
Witold Filipczyk 2024-03-07 11:44:42 +01:00
parent 9c04585e84
commit b102addf9f
3 changed files with 20 additions and 11 deletions

View File

@ -73,21 +73,22 @@ static void
sig_tstp(struct terminal *term) sig_tstp(struct terminal *term)
{ {
#ifdef SIGSTOP #ifdef SIGSTOP
pid_t newpid;
pid_t pid = getpid(); pid_t pid = getpid();
block_itrm(); block_itrm();
#if defined (SIGCONT) && defined(SIGTTOU) #if defined (SIGCONT) && defined(SIGTTOU)
newpid = fork(); if (pid == master_pid) {
if (!newpid) { pid_t newpid = fork();
sleep(1); if (!newpid) {
kill(pid, SIGCONT); sleep(1);
/* Use _exit() rather than exit(), so that atexit kill(pid, SIGCONT);
* functions are not called, and stdio output buffers /* Use _exit() rather than exit(), so that atexit
* are not flushed. Any such things must have been * functions are not called, and stdio output buffers
* inherited from the parent process, which will take * are not flushed. Any such things must have been
* care of them when appropriate. */ * inherited from the parent process, which will take
_exit(0); * care of them when appropriate. */
_exit(0);
}
} }
#endif #endif
raise(SIGSTOP); raise(SIGSTOP);

View File

@ -54,6 +54,8 @@ INIT_LIST_OF(struct terminal, terminals);
struct hash *temporary_files; struct hash *temporary_files;
static void check_if_no_terminal(void); static void check_if_no_terminal(void);
pid_t master_pid = 0;
void void
clean_temporary_files(void) clean_temporary_files(void)
{ {
@ -188,6 +190,11 @@ init_term(int fdin, int fdout)
term->fdin = fdin; term->fdin = fdin;
term->fdout = fdout; term->fdout = fdout;
term->master = (term->fdout == get_output_handle()); term->master = (term->fdout == get_output_handle());
if (term->master) {
master_pid = getpid();
}
term->blocked = -1; term->blocked = -1;
get_terminal_name(name + 9); get_terminal_name(name + 9);

View File

@ -14,6 +14,7 @@ struct option;
struct terminal_screen; struct terminal_screen;
struct terminal_interlink; struct terminal_interlink;
extern pid_t master_pid;
/** The terminal type, meaningful for frames (lines) drawing. */ /** The terminal type, meaningful for frames (lines) drawing. */
enum term_mode_type { enum term_mode_type {