From 8b414aac13dc580432d433cf8039185c128a1d80 Mon Sep 17 00:00:00 2001 From: Jack Halford Date: Tue, 10 Jan 2017 17:07:25 +0100 Subject: [PATCH] merge stash --- 42sh/includes/lexer.h | 2 +- 42sh/src/job-control/do_job_notification.c | 2 +- 42sh/src/job-control/job_is_completed.c | 6 +++--- 42sh/src/job-control/put_job_in_foreground.c | 4 ++-- 42sh/src/job-control/sigtstp_handler.c | 8 ++++++-- 42sh/src/lexer/ft_tokenize.c | 3 +-- 42sh/src/lexer/lexer_var.c | 3 +-- 42sh/src/lexer/token_expand_var.c | 2 +- 42sh/src/line-editing/rl_prompt.c | 3 ++- 42sh/src/line-editing/rl_setup.c | 3 ++- 42sh/src/main/data_init.c | 2 +- 42sh/src/main/main.c | 2 +- 42sh/src/main/shell_exit.c | 12 +++--------- 42sh/src/main/shell_init.c | 2 +- 14 files changed, 26 insertions(+), 28 deletions(-) diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 294ab517..e0d43963 100644 --- a/42sh/includes/lexer.h +++ b/42sh/includes/lexer.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/01 12:15:50 by jhalford #+# #+# */ -/* Updated: 2017/01/10 15:04:28 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:49:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/do_job_notification.c b/42sh/src/job-control/do_job_notification.c index 891f062d..00dcc021 100644 --- a/42sh/src/job-control/do_job_notification.c +++ b/42sh/src/job-control/do_job_notification.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 13:01:19 by jhalford #+# #+# */ -/* Updated: 2017/01/10 17:04:27 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 17:05:31 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job-control/job_is_completed.c b/42sh/src/job-control/job_is_completed.c index 11ce8b55..ba1837a2 100644 --- a/42sh/src/job-control/job_is_completed.c +++ b/42sh/src/job-control/job_is_completed.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 15:10:20 by jhalford #+# #+# */ -/* Updated: 2017/01/10 12:30:33 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:41:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,10 +25,10 @@ int job_is_completed(int id) while (lst) { p = lst->content; - /* DG("checking pid=%i", p->pid); */ + DG("checking pid=%i", p->pid); if (!(p->attributes & PROCESS_COMPLETED)) { - /* DG("process %i is not completed", p->pid); */ + DG("process %i is not completed", p->pid); return (0); } lst = lst->next; diff --git a/42sh/src/job-control/put_job_in_foreground.c b/42sh/src/job-control/put_job_in_foreground.c index ed4b03cb..34a8f115 100644 --- a/42sh/src/job-control/put_job_in_foreground.c +++ b/42sh/src/job-control/put_job_in_foreground.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 14:58:36 by jhalford #+# #+# */ -/* Updated: 2017/01/10 16:56:52 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 17:06:23 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,7 +30,7 @@ int put_job_in_foreground(t_job *job, int cont) perror("kill (SIGCONT)"); } /* Wait for it to report. */ - /* DG("gonna wait for job id=%i", job->id); */ + DG("gonna wait for job id=%i", job->id); job_wait(job->id); job_remove(job->id); diff --git a/42sh/src/job-control/sigtstp_handler.c b/42sh/src/job-control/sigtstp_handler.c index aa138934..ce6a84ce 100644 --- a/42sh/src/job-control/sigtstp_handler.c +++ b/42sh/src/job-control/sigtstp_handler.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */ -/* Updated: 2017/01/10 10:30:27 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:49:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -14,6 +14,10 @@ void sigtstp_handler(int signo) { + t_jobc *jobc; + (void)signo; - DG("got SIGTSTP"); + jobc = &data_singleton()->jobc; + DG("got SIGTSTP in process %i", getpid()); + kill(jobc->shell_pgid, SIGCONT); } diff --git a/42sh/src/lexer/ft_tokenize.c b/42sh/src/lexer/ft_tokenize.c index 4bb42418..2d446de8 100644 --- a/42sh/src/lexer/ft_tokenize.c +++ b/42sh/src/lexer/ft_tokenize.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/10 13:37:11 by jhalford #+# #+# */ -/* Updated: 2017/01/10 15:15:27 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:37:30 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -38,7 +38,6 @@ int ft_tokenize(t_list **alst, char *str, t_lexstate state) { t_token *token; - DG("state=%i, *str=%c", state, *str); if (!*str) return (0); if (!*alst) diff --git a/42sh/src/lexer/lexer_var.c b/42sh/src/lexer/lexer_var.c index 881cc70a..61011338 100644 --- a/42sh/src/lexer/lexer_var.c +++ b/42sh/src/lexer/lexer_var.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 14:54:57 by jhalford #+# #+# */ -/* Updated: 2017/01/10 15:19:44 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:36:15 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -20,7 +20,6 @@ int lexer_var(t_list **alst, char *str) token = (*alst)->content; token->type = TK_N_WORD; str++; - DG("check, *str=%c, data='%s'", *str, token->data); if (!ft_strchr(token->data, '$')) token_append(token, '$'); if (!*str) diff --git a/42sh/src/lexer/token_expand_var.c b/42sh/src/lexer/token_expand_var.c index 9ce64813..b729611c 100644 --- a/42sh/src/lexer/token_expand_var.c +++ b/42sh/src/lexer/token_expand_var.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/10 14:57:53 by jhalford #+# #+# */ -/* Updated: 2017/01/10 15:19:47 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:37:33 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line-editing/rl_prompt.c b/42sh/src/line-editing/rl_prompt.c index 81d8fdb3..3dc9e4f0 100644 --- a/42sh/src/line-editing/rl_prompt.c +++ b/42sh/src/line-editing/rl_prompt.c @@ -6,11 +6,12 @@ /* By: sbenning +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/09 01:45:09 by sbenning #+# #+# */ -/* Updated: 2017/01/10 11:43:12 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:41:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "ft_readline.h" +#include "job_control.h" void rl_set_prompt(t_line *line) { diff --git a/42sh/src/line-editing/rl_setup.c b/42sh/src/line-editing/rl_setup.c index 2b217db5..3f76ca34 100644 --- a/42sh/src/line-editing/rl_setup.c +++ b/42sh/src/line-editing/rl_setup.c @@ -6,7 +6,7 @@ /* By: sbenning +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/08 18:07:47 by sbenning #+# #+# */ -/* Updated: 2017/01/10 17:02:48 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 17:06:13 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ int rl_setup(t_line *line) { rl_set_termios(1); + do_job_notification(); ft_bzero(line, sizeof(t_line)); if (curs_setup(&line->curs) < 0) return (-1); diff --git a/42sh/src/main/data_init.c b/42sh/src/main/data_init.c index 1e09464b..d32470ee 100644 --- a/42sh/src/main/data_init.c +++ b/42sh/src/main/data_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */ -/* Updated: 2017/01/10 13:16:23 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:49:28 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/main.c b/42sh/src/main/main.c index 3a2401d0..dfa083cd 100644 --- a/42sh/src/main/main.c +++ b/42sh/src/main/main.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */ -/* Updated: 2017/01/10 14:20:28 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:50:35 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/main/shell_exit.c b/42sh/src/main/shell_exit.c index a662e530..0983fa88 100644 --- a/42sh/src/main/shell_exit.c +++ b/42sh/src/main/shell_exit.c @@ -6,22 +6,16 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:37:04 by jhalford #+# #+# */ -/* Updated: 2017/01/10 13:13:51 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 16:51:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -extern char **environ; -extern char PC; -extern char *UP; -extern char *BC; - void shell_exit(void) { - /* DG("cleanup. char * UP at %p", UP); */ - /* DG("cleanup. char * BC at %p", BC); */ + DG("shell_exit()"); data_exit(); job_kill_all(); - tcsetattr(0, TCSANOW, &data_singleton()->jobc.shell_tmodes); + tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); } diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index 26e72a04..3031469b 100644 --- a/42sh/src/main/shell_init.c +++ b/42sh/src/main/shell_init.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 17:23:59 by jhalford #+# #+# */ -/* Updated: 2017/01/10 17:00:46 by jhalford ### ########.fr */ +/* Updated: 2017/01/10 17:05:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */