93 lines
2.2 KiB
C
93 lines
2.2 KiB
C
# include <stdio.h>
|
|
# include <stdlib.h>
|
|
# include <unistd.h>
|
|
# include <readline/readline.h>
|
|
# include <signal.h>
|
|
//# include <readline/history.h>
|
|
//# include <fcntl.h>
|
|
//# include <sys/ioctl.h>
|
|
//# include <string.h>
|
|
//# include <errno.h>
|
|
//# include <sys/wait.h>
|
|
//# include <sys/stat.h>
|
|
//# include <sys/types.h>
|
|
//# include <sys/time.h>
|
|
//# include <sys/resource.h>
|
|
//# include <dirent.h>
|
|
//# include <termios.h>
|
|
//# include <curses.h>
|
|
//# include <term.h>
|
|
|
|
void handler_sigint(int id)
|
|
{
|
|
(void)id;
|
|
write(1, "\n", 1);
|
|
}
|
|
|
|
int main(int argc, char *argv[], char *envp[])
|
|
{
|
|
(void)argc;
|
|
(void)argv;
|
|
char *line_input;
|
|
char *prompt;
|
|
|
|
// t_cmd **cmd_arr;
|
|
// char **envp;
|
|
// char *prompt_base;
|
|
// char *prompt;
|
|
// t_token *token_list;
|
|
// int last_exit_status;
|
|
// struct termios ori_termios;
|
|
// struct termios interactive_termios;
|
|
// int termios_changed;
|
|
// struct sigaction ori_signal_behaviour;
|
|
// struct sigaction signal_behaviour;
|
|
|
|
signal(SIGINT, handler_sigint);
|
|
line_input = NULL;
|
|
prompt = strdup("\e[0;31mtest>\e[0m ");
|
|
while (1)
|
|
{
|
|
if (line_input)
|
|
free(line_input);
|
|
line_input = readline(prompt);
|
|
if (line_input && *line_input)
|
|
{
|
|
// A faire aprés être sortie du mode interactif
|
|
// - Ignorer tout les signaux
|
|
// - Remettre ori_termios
|
|
// c->signal_behaviour.sa_handler = SIG_IGN;
|
|
// sigaction(SIGINT, &c->signal_behaviour, NULL);
|
|
// sigaction(SIGQUIT, &c->signal_behaviour, NULL);
|
|
// tcsetattr(STDIN_FILENO, TCSANOW, &c->ori_termios);
|
|
// if (!fork())
|
|
// {
|
|
// char *arg_test[3];
|
|
//
|
|
// arg_test[0] = ft_strdup("sleep");
|
|
// arg_test[1] = ft_strdup("3");
|
|
// arg_test[2] = NULL;
|
|
// sigaction(SIGQUIT, &c->ori_signal_behaviour, NULL);
|
|
// sigaction(SIGINT, &c->ori_signal_behaviour, NULL);
|
|
// execve("/bin/sleep", arg_test, c->envp);
|
|
// }
|
|
// else
|
|
// {
|
|
// int wait_test;
|
|
// wait(&wait_test);
|
|
// c->signal_behaviour.sa_handler = sigint_handler;
|
|
// sigaction(SIGINT, &c->signal_behaviour, NULL);
|
|
// c->signal_behaviour.sa_handler = SIG_IGN;
|
|
// sigaction(SIGQUIT, &c->signal_behaviour, NULL);
|
|
// tcsetattr(STDIN_FILENO, TCSANOW, &c->interactive_termios);
|
|
// }
|
|
|
|
printf("%s\n", line_input);
|
|
}
|
|
else if (!line_input)
|
|
write(1, "\n", 1);
|
|
}
|
|
|
|
return (0);
|
|
}
|