stdin을 통해 입력을 받아 작동하는 프로그램을 쉘에서 실행하고 백드라운드로 돌리니 멈춘다?!
bg [1] /test # [1]+ Stopped (tty input) /test |
[링크 : https://topic.alibabacloud.com/...-stopped-tty-input_1_16_30150438.html]
[링크 : https://unix.stackexchange.com/questions/294471/backgrounded-job-keeps-stopping]
아무튼 SIGTTIN이 들어와서 그렇다고 하는데
간단하게는.. 해당 시그널을 무시하면 되는거고..
다른 방법은 좀 더 고민해 봐야 할 듯 -_-
void
init_shell ()
{
/* See if we are running interactively. */
shell_terminal = STDIN_FILENO;
shell_is_interactive = isatty (shell_terminal);
if (shell_is_interactive)
{
/* Loop until we are in the foreground. */
while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
kill (- shell_pgid, SIGTTIN);
/* Ignore interactive and job-control signals. */
signal (SIGINT, SIG_IGN);
signal (SIGQUIT, SIG_IGN);
signal (SIGTSTP, SIG_IGN);
signal (SIGTTIN, SIG_IGN);
signal (SIGTTOU, SIG_IGN);
signal (SIGCHLD, SIG_IGN);
/* Put ourselves in our own process group. */
shell_pgid = getpid ();
if (setpgid (shell_pgid, shell_pgid) < 0)
{
perror ("Couldn't put the shell in its own process group");
exit (1);
}
/* Grab control of the terminal. */
tcsetpgrp (shell_terminal, shell_pgid);
/* Save default terminal attributes for shell. */
tcgetattr (shell_terminal, &shell_tmodes);
}
}
[링크 : https://www.gnu.org/software/libc/manual/html_node/Initializing-the-Shell.html]
Macro: int SIGTTINA process cannot read from the user’s terminal while it is running as a background job. When any process in a background job tries to read from the terminal, all of the processes in the job are sent a SIGTTIN signal. The default action for this signal is to stop the process. For more information about how this interacts with the terminal driver, see Access to the Terminal. |
[링크 : https://www.gnu.org/software/libc/manual/html_node/Job-Control-Signals.html]
'Linux API > linux' 카테고리의 다른 글
select, poll, epoll (0) | 2021.11.02 |
---|---|
Unhandled fault: external abort on non-linefetch (0) | 2021.05.25 |
linux gpio interrupt poll? (0) | 2021.05.04 |
Floating point exception (0) | 2021.04.05 |
실행파일 not fount, FATAL: kernel too old (0) | 2021.04.05 |