1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-20 00:15:31 +00: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)
{
#ifdef SIGSTOP
pid_t newpid;
pid_t pid = getpid();
block_itrm();
#if defined (SIGCONT) && defined(SIGTTOU)
newpid = fork();
if (!newpid) {
sleep(1);
kill(pid, SIGCONT);
/* Use _exit() rather than exit(), so that atexit
* functions are not called, and stdio output buffers
* are not flushed. Any such things must have been
* inherited from the parent process, which will take
* care of them when appropriate. */
_exit(0);
if (pid == master_pid) {
pid_t newpid = fork();
if (!newpid) {
sleep(1);
kill(pid, SIGCONT);
/* Use _exit() rather than exit(), so that atexit
* functions are not called, and stdio output buffers
* are not flushed. Any such things must have been
* inherited from the parent process, which will take
* care of them when appropriate. */
_exit(0);
}
}
#endif
raise(SIGSTOP);

View File

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

View File

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