我创建了一个程序,它接受一个参数列表并将它们放在一个新 tty 上的网格中,我可以在其中移动并从中选择我想要的。
当我像这样运行没有反引号的程序时......
$> ./ft_select arg_1 arg_2 ... arg_N
打开一个新的 tty 并显示一个网格...
arg_1 arg_2 arg_3
arg_4 arg_5 arg_6
arg_7 ... arg_N
我点击ctrl+z了,程序毫无问题地被挂起,fg
命令将其放回原处。
我的问题是,当我将命令放在反引号之间并尝试暂停它时,它会卡住而没有给出提示。
不得不提的是,我把网格的所有内容都写在/dev/tty
您可以在下面的代码中找到执行信号处理的函数。
23 void signalhandler(int sig)
24 {
25 // struct winsize ws;
26
27 if (sig == SIGWINCH)
28 {
29 // ioctl(g_data->tty, TIOCGWINSZ, &ws);
30 update_data(g_data);
31 print_args(g_data);
32 update_cursor(g_data, 1);
33 }
34 else if (sig == SIGTSTP)
35 {
36 signal(SIGTSTP, SIG_DFL);
37 enable_cap("te");
38 modify_main_caps(SET, g_data->tty);
39 ioctl(g_data->tty, TIOCSTI, "\032");
40 }
41 else if (sig == SIGCONT)
42 {
43 signal(SIGTSTP, signalhandler);
44 modify_main_caps(UNSET, g_data->tty);
45 update_data(g_data);
46 print_args(g_data);
47 update_cursor(g_data, 1);
48 }
49 else if (sig == SIGINT)
50 {
51 enable_cap("te");
52 modify_main_caps(SET, g_data->tty);
53 exit(EXIT_FAILURE);
54 }
55 }