signals and termios WIP
+ shell script placeholder + generics functions + valgrind add_history() supp + misc
This commit is contained in:
84
srcs/signals.c
Normal file
84
srcs/signals.c
Normal file
@@ -0,0 +1,84 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* signals.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/10/23 18:56:53 by lperrey #+# #+# */
|
||||
/* Updated: 2021/10/30 14:28:08 by lperrey ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "minishell.h"
|
||||
|
||||
void sigint_handler(int signum)
|
||||
{
|
||||
// Comment virer LE ^D De l'affichage ? Il ne fait pas partie de "rl_line_buffer".
|
||||
if (rl_line_buffer && *rl_line_buffer)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
else
|
||||
{
|
||||
free_exit(g_all, g_all->last_exit_status);
|
||||
}
|
||||
return ;
|
||||
}
|
||||
|
||||
/* void sigquit_aka_eof_handler(int signum)
|
||||
{
|
||||
//ft_putstr_fd("TESTS\n", 1);
|
||||
ft_putstr_fd("\n", 1);
|
||||
rl_replace_line("", 1);
|
||||
rl_on_new_line();
|
||||
rl_redisplay();
|
||||
return ;
|
||||
} */
|
||||
|
||||
int set_signals_handling(struct sigaction *ori_signal_behaviour,
|
||||
struct sigaction *signal_behaviour)
|
||||
{
|
||||
ori_signal_behaviour->sa_handler = SIG_DFL;
|
||||
|
||||
/* ctrl-D exit the shell.
|
||||
eof = ^D; */
|
||||
signal_behaviour->sa_handler = sigint_handler;
|
||||
sigaction(SIGINT, signal_behaviour, NULL);
|
||||
|
||||
/* ctrl-\ do nothing.
|
||||
quit = ^\; */
|
||||
signal_behaviour->sa_handler = SIG_IGN;
|
||||
//signal_behaviour->sa_handler = sigquit_aka_eof_handler;
|
||||
sigaction(SIGQUIT, signal_behaviour, NULL);
|
||||
|
||||
/*
|
||||
** remap (^D to ^C) and (^C to ^D) in terminal
|
||||
** ^D is now "SIGINT" (handle here)
|
||||
** ^C is now EOF (handle in shell_loop())
|
||||
*/
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
ctrl-C print a new prompt on a newline.
|
||||
intr = ^C;
|
||||
ctrl-D exit the shell.
|
||||
eof = ^D;
|
||||
ctrl-\ do nothing.
|
||||
quit = ^\;
|
||||
*/
|
||||
|
||||
/*
|
||||
speed 38400 baud; rows 22; columns 90; line = 0;
|
||||
erase = ^?; kill = ^U;
|
||||
eol = M-^?; eol2 = M-^?;
|
||||
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V;
|
||||
discard = ^O; min = 1; time = 0;
|
||||
-parenb -parodd -cmspar cs8 hupcl -cstopb cread -clocal -crtscts
|
||||
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany
|
||||
imaxbel iutf8
|
||||
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
|
||||
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke
|
||||
-flusho -extproc
|
||||
*/
|
||||
Reference in New Issue
Block a user