diff --git a/42sh/Makefile b/42sh/Makefile index d76d7dbe..8f8e4c79 100644 --- a/42sh/Makefile +++ b/42sh/Makefile @@ -180,9 +180,9 @@ job_control/job_format_head.c\ job_control/job_free.c\ job_control/job_getprocess.c\ job_control/job_getrank.c\ +job_control/job_hup_all.c\ job_control/job_is_completed.c\ job_control/job_is_stopped.c\ -job_control/job_kill_all.c\ job_control/job_notify_change.c\ job_control/job_notify_new.c\ job_control/job_remove.c\ diff --git a/42sh/includes/builtin_read.h b/42sh/includes/builtin_read.h index c40d11e4..25f39efa 100644 --- a/42sh/includes/builtin_read.h +++ b/42sh/includes/builtin_read.h @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* builtin_read.h :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/20 15:02:39 by jhalford #+# #+# */ -/* Updated: 2017/03/15 19:13:26 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:36:08 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,17 +30,18 @@ typedef struct s_readopt t_readopt; struct s_read { - t_flag opts; - char **names; - char delim; - int nchars; - char *prompt; - int timeout; - int fd; - char *input; + t_flag opts; + char **names; + char delim; + int nchars; + char *prompt; + int timeout; + int fd; + char *input; }; -int builtin_read(const char *path, char *const av[], char *const envp[]); +int builtin_read(const char *path, char *const av[], + char *const envp[]); int bt_read_init(t_read *data, char **av); diff --git a/42sh/includes/ft_curs.h b/42sh/includes/ft_curs.h index 94b1a6bd..d411b2c5 100644 --- a/42sh/includes/ft_curs.h +++ b/42sh/includes/ft_curs.h @@ -6,7 +6,7 @@ /* By: sbenning +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/08 16:34:51 by sbenning #+# #+# */ -/* Updated: 2017/03/15 18:47:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:33:06 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,7 +27,7 @@ typedef struct s_curs t_curs; ** Cursor data : cursor's coordonate and windows size */ -struct s_curs +struct s_curs { int co; int li; @@ -79,6 +79,6 @@ void curs_write(t_curs *curs, char *str, size_t len); void curs_write_static(t_curs *curs, char *str, size_t len); void curs_video_write(t_curs *curs, char *str, size_t len); void curs_video_write_static( - t_curs *curs, char *str, size_t len); + t_curs *curs, char *str, size_t len); #endif diff --git a/42sh/includes/ft_readline.h b/42sh/includes/ft_readline.h index 4282c854..9d78c82b 100644 --- a/42sh/includes/ft_readline.h +++ b/42sh/includes/ft_readline.h @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/23 10:35:44 by gwojda #+# #+# */ -/* Updated: 2017/03/17 17:24:03 by gwojda ### ########.fr */ +/* Updated: 2017/03/20 12:32:15 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -57,9 +57,6 @@ # define CORRUPT 1 -//# define STR data_singleton()->line.input -//# define POS data_singleton()->line.pos - # define ERROR_CNTL_R 1 typedef struct s_list_history diff --git a/42sh/includes/job_control.h b/42sh/includes/job_control.h index 08f66b66..78d034c5 100644 --- a/42sh/includes/job_control.h +++ b/42sh/includes/job_control.h @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/10 16:55:09 by jhalford #+# #+# */ -/* Updated: 2017/03/17 23:10:35 by wescande ### ########.fr */ +/* Updated: 2017/03/20 11:38:24 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -58,7 +58,7 @@ void job_run(t_job *job, int foreground); int job_wait(int id); void job_remove(int id); void job_free(void *content, size_t content_size); -void job_kill_all(void); +void job_hup_all(void); int put_job_in_foreground(t_job *job, int cont); int put_job_in_background(t_job *job, int cont); @@ -79,7 +79,7 @@ void process_format(t_list **p, int firstp, int opts); ** Mapping pour afficher les process */ void pprint(t_process *p); -int pprint_subshell(t_process *p); +int pprint_subshell(t_process *p);; int pprint_brace(t_process *p); int pprint_while(t_process *p); int pprint_if(t_process *p); diff --git a/42sh/includes/lexer.h b/42sh/includes/lexer.h index 2920d059..0724da9d 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/03/20 11:22:08 by wescande ### ########.fr */ +/* Updated: 2017/03/20 14:43:04 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -63,9 +63,8 @@ struct s_rvwords int type; }; -extern t_rvwords g_rvwords[]; - -extern int (*g_lexer[])(t_list **alst, t_lexer *lexer); +/* extern t_rvwords g_rvwords[]; */ +/* extern int (*g_lexer[])(t_list **alst, t_lexer *lexer); */ int ft_post_tokenize(t_list **alst, char **str); diff --git a/42sh/includes/parser.h b/42sh/includes/parser.h index 6bd7ac30..1fa276a9 100644 --- a/42sh/includes/parser.h +++ b/42sh/includes/parser.h @@ -94,8 +94,6 @@ struct s_treematch int (*add)(t_btree **ast, t_list **lst); }; -extern t_treematch g_treematch[]; - int build_tree(t_btree **ast, t_list **lst); int add_sep(t_btree **ast, t_list **lst); @@ -153,7 +151,8 @@ struct s_distrostree int (*add)(t_btree **ast, t_list **lst); }; -extern t_distrostree g_distrostree[]; +/* extern t_distrostree g_distrostree[]; */ +/* extern t_treematch g_treematch[]; */ struct s_redir { diff --git a/42sh/libft/src/lst/ft_lstmap.c b/42sh/libft/src/lst/ft_lstmap.c index 3b422790..3a36ef41 100644 --- a/42sh/libft/src/lst/ft_lstmap.c +++ b/42sh/libft/src/lst/ft_lstmap.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/03 14:57:21 by jhalford #+# #+# */ -/* Updated: 2017/03/08 12:03:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:25:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -18,7 +18,9 @@ t_list *ft_lstmap(t_list *lst, void *(*f)(void *)) if (!lst) return (NULL); - elem = ft_lstnew((*f)(lst->content), lst->content_size); + if (!(elem = (t_list *)malloc(sizeof(*elem)))) + return (NULL); + elem->content = (*f)(lst->content); elem->next = ft_lstmap(lst->next, f); return (elem); } diff --git a/42sh/libft/src/lst/ft_lstnew.c b/42sh/libft/src/lst/ft_lstnew.c index e85e8c62..17a43d6f 100644 --- a/42sh/libft/src/lst/ft_lstnew.c +++ b/42sh/libft/src/lst/ft_lstnew.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */ -/* Updated: 2017/03/13 15:41:27 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:23:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/libft/src/math/id.c b/42sh/libft/src/math/id.c index 938cb5d1..e23a5831 100644 --- a/42sh/libft/src/math/id.c +++ b/42sh/libft/src/math/id.c @@ -1,3 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* id.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: jhalford +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2017/03/20 12:20:59 by jhalford #+# #+# */ +/* Updated: 2017/03/20 12:21:01 by jhalford ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "libft.h" void *id(void *data) diff --git a/42sh/src/builtin/bt_read_term.c b/42sh/src/builtin/bt_read_term.c index 0ba68f65..2fb1d5f1 100644 --- a/42sh/src/builtin/bt_read_term.c +++ b/42sh/src/builtin/bt_read_term.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* bt_read_term.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/25 16:02:05 by jhalford #+# #+# */ -/* Updated: 2017/03/15 21:23:41 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 14:23:46 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -21,7 +21,7 @@ struct termios bt_read_term(int init) return (term); } -int bt_read_terminit(t_read *data) +int bt_read_terminit(t_read *data) { struct termios term; @@ -39,7 +39,7 @@ int bt_read_terminit(t_read *data) return (0); } -int bt_read_exit(t_read *data) +int bt_read_exit(t_read *data) { struct termios term; diff --git a/42sh/src/builtin/builtin_env.c b/42sh/src/builtin/builtin_env.c index 4ef5c73c..735916b7 100644 --- a/42sh/src/builtin/builtin_env.c +++ b/42sh/src/builtin/builtin_env.c @@ -6,14 +6,14 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:14:20 by jhalford #+# #+# */ -/* Updated: 2017/03/20 12:52:05 by wescande ### ########.fr */ +/* Updated: 2017/03/20 14:43:49 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" #define US_ENV "env [-i] [-u name] [name=value]... [utility [argument...]]" -static int env_usage(int arg_miss, char c) +static int env_usage(int arg_miss, char c) { if (arg_miss) ft_dprintf(2, "{red}env: option requires an argument -- u{eoc}\n"); @@ -23,7 +23,7 @@ static int env_usage(int arg_miss, char c) return (1); } -static void env_freeone(char **env, char *arg) +static void env_freeone(char **env, char *arg) { int i; char *tmp; @@ -46,7 +46,7 @@ static void env_freeone(char **env, char *arg) } } -static void env_replace(char ***custom_env, char *arg) +static void env_replace(char ***custom_env, char *arg) { char **arg_split; @@ -58,7 +58,7 @@ static void env_replace(char ***custom_env, char *arg) *custom_env = ft_sstradd(*custom_env, arg); } -static int env_treat_flag(char ***custom_env, char *const *arg[]) +static int env_treat_flag(char ***custom_env, char *const *arg[]) { while (*(++*arg)) { diff --git a/42sh/src/builtin/builtin_exit.c b/42sh/src/builtin/builtin_exit.c index d38bd167..2e56a7d5 100644 --- a/42sh/src/builtin/builtin_exit.c +++ b/42sh/src/builtin/builtin_exit.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */ -/* Updated: 2017/03/18 15:41:42 by gwojda ### ########.fr */ +/* Updated: 2017/03/20 14:17:40 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -26,15 +26,15 @@ int builtin_exit(const char *path, char *const av[], char *const envp[]) if (SH_HAS_JOBC(data_singleton()->opts) && jlist && !notified) { notified = 1; - ft_dprintf(2, "{red}%s: you have live jobs (running or suspended).{eoc}\n", SHELL_NAME); + ft_dprintf(2, "%s: you have live jobs (running or suspended)\n", + data_singleton()->argv[0]); return (0); } - if (av && av[1]) - status = ft_atoi(av[1]); - else - status = ft_atoi(ft_getenv(data_singleton()->env, "?")); + status = (av && av[1]) ? + ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?")); if (SH_IS_INTERACTIVE(data_singleton()->opts)) tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); + job_hup_all(); data_exit(); exit(status); return (0); diff --git a/42sh/src/builtin/builtin_export.c b/42sh/src/builtin/builtin_export.c index 6cade0bb..4eee266a 100644 --- a/42sh/src/builtin/builtin_export.c +++ b/42sh/src/builtin/builtin_export.c @@ -6,13 +6,13 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/02/15 11:39:37 by gwojda #+# #+# */ -/* Updated: 2017/03/20 14:01:11 by wescande ### ########.fr */ +/* Updated: 2017/03/20 14:44:02 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -static t_cliopts export_opts[] = +static t_cliopts g_export_opts[] = { {'p', NULL, BT_EXPORT_LP, 0, NULL}, {0, NULL, 0, 0, NULL}, @@ -44,23 +44,20 @@ int builtin_export( (void)envp; (void)path; data.flag = 0; - if (cliopts_get((char**)av, export_opts, &data)) + if (cliopts_get((char**)av, g_export_opts, &data)) ft_perror(); if (data.flag & BT_EXPORT_LP) return (builtin_return_status(0, bt_export_print())); av = data.av_data; while (*av) { - if ((equal = ft_strchr(*av, '='))) - { + equal = ft_strchr(*av, '='); + if (equal) *equal = 0; - builtin_setenv("internal", (char*[]){"global", *av, equal + 1}, NULL); - } else - { equal = ft_getenv(data_singleton()->local_var, *av); - builtin_setenv("internal", (char*[]){"global", *av, equal}, NULL); - } + equal ? equal++ : equal; + builtin_setenv("internal", (char*[]){"global", *av, equal}, NULL); builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL); av++; } diff --git a/42sh/src/builtin/builtin_math.c b/42sh/src/builtin/builtin_math.c index 85bdc610..c6658e9d 100644 --- a/42sh/src/builtin/builtin_math.c +++ b/42sh/src/builtin/builtin_math.c @@ -6,17 +6,17 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/17 18:54:00 by ariard #+# #+# */ -/* Updated: 2017/03/20 14:14:59 by wescande ### ########.fr */ +/* Updated: 2017/03/20 14:45:09 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -# define MATHERR_0 "math : invalid number of arguments\n" -# define MATHERR_1 "math : invalid variable name\n" -# define MATHERR_2 "math : invalid operator\n" -# define MATHERR_3 "math : invalid operand\n" -# define MATHERR_4 "math : division by 0\n" +#define MATHERR_0 "math : invalid number of arguments\n" +#define MATHERR_1 "math : invalid variable name\n" +#define MATHERR_2 "math : invalid operator\n" +#define MATHERR_3 "math : invalid operand\n" +#define MATHERR_4 "math : division by 0\n" static int error_msg(char *msg) { @@ -38,7 +38,7 @@ static int get_value(char *var, char **value) { char *temp; char *esc; - int ret; + int ret; esc = ft_strnew((ft_strlen(var) >> 3) + 1); ret = word_is_assignment((char *[]) {var, (esc + 1)}); @@ -109,6 +109,6 @@ int builtin_math(const char *path, char *const av[], char *const envp[]) return (builtin_return_status(0, error_msg(MATHERR_3))); if (do_math(&value, operator, operand)) return (builtin_return_status(0, 1)); - builtin_setenv("setenv", (char *[]){"local", var, value, 0}, data_singleton()->local_var); + builtin_setenv("setenv", (char *[]){"local", var, value, 0}, NULL); return (builtin_return_status(0, 0)); } diff --git a/42sh/src/builtin/builtin_read.c b/42sh/src/builtin/builtin_read.c index 935ab533..3474d32e 100644 --- a/42sh/src/builtin/builtin_read.c +++ b/42sh/src/builtin/builtin_read.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* builtin_read.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ +/* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/20 15:01:45 by jhalford #+# #+# */ -/* Updated: 2017/03/20 12:53:06 by wescande ### ########.fr */ +/* Updated: 2017/03/20 14:46:56 by wescande ### ########.fr */ /* */ /* ************************************************************************** */ @@ -41,13 +41,13 @@ int bt_read_init(t_read *data, char **av) data->timeout = 0; data->input = NULL; if ((cliopts_get(av, g_read_opts, data))) - return(ft_perror() ? 2 : 2); + return (ft_perror() ? 2 : 2); if (bt_read_terminit(data) < 0) return (-1); return (0); } -int bt_read_loop(t_read *data) +int bt_read_loop(t_read *data) { int i; int esc; @@ -75,7 +75,7 @@ int bt_read_loop(t_read *data) return (0); } -int bt_read_assign(t_read *data) +int bt_read_assign(t_read *data) { char *input; char **names; @@ -98,7 +98,7 @@ int bt_read_assign(t_read *data) return (0); } -int builtin_read(const char *path, char *const av[], char *const envp[]) +int builtin_read(const char *path, char *const av[], char *const envp[]) { t_read data; int ret; diff --git a/42sh/src/exec/exec_reset.c b/42sh/src/exec/exec_reset.c index b83d6928..45e91663 100644 --- a/42sh/src/exec/exec_reset.c +++ b/42sh/src/exec/exec_reset.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 14:31:42 by jhalford #+# #+# */ -/* Updated: 2017/03/20 08:51:51 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:35:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -30,7 +30,7 @@ int exec_reset(void) exec->attrs = 0; exec->job.id = 0; exec->job.pgid = 0; - exec->job.attrs = 0; + exec->job.attrs = JOB_NOTIFIED; exec->job.first_process = NULL; tcgetattr(STDIN, &exec->job.tmodes); jobc->first_job = NULL; diff --git a/42sh/src/exec/process_set.c b/42sh/src/exec/process_set.c index b3f61ed8..b2ce7cfc 100644 --- a/42sh/src/exec/process_set.c +++ b/42sh/src/exec/process_set.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:57:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:22:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redir_copy.c b/42sh/src/exec/redir_copy.c index 055efcd4..5dd758c9 100644 --- a/42sh/src/exec/redir_copy.c +++ b/42sh/src/exec/redir_copy.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/08 00:02:58 by ariard #+# #+# */ -/* Updated: 2017/03/13 14:20:56 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:21:26 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/exec/redir_free.c b/42sh/src/exec/redir_free.c index 09665cd9..2cc00e05 100644 --- a/42sh/src/exec/redir_free.c +++ b/42sh/src/exec/redir_free.c @@ -6,7 +6,7 @@ /* By: ariard +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/03/03 18:12:57 by ariard #+# #+# */ -/* Updated: 2017/03/18 18:59:57 by ariard ### ########.fr */ +/* Updated: 2017/03/20 12:21:21 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/history/surch_in_history.c b/42sh/src/history/surch_in_history.c index 69c3a8a0..6c16b270 100644 --- a/42sh/src/history/surch_in_history.c +++ b/42sh/src/history/surch_in_history.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/26 10:43:16 by gwojda #+# #+# */ -/* Updated: 2017/03/18 14:29:15 by gwojda ### ########.fr */ +/* Updated: 2017/03/20 14:09:01 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -23,7 +23,7 @@ static void ft_clear_prompt(size_t *pos, size_t srch_pos) ft_puttermcaps("cd"); } -static int ft_surch_and_realloc(char **str, char **str_srch, +static int search(char **str, char **str_srch, int ret, size_t *srch_pos) { if (!(*str_srch = ft_realloc_imput(*str_srch, ret, *srch_pos))) @@ -51,7 +51,7 @@ static void ft_give_new_prompt(char *str_srch, size_t srch_pos) } } -static void ft_modify_str(char *str_srch, size_t srch_pos, char **str, +static int ft_modify_str(char *str_srch, size_t srch_pos, char **str, size_t *pos) { ft_clear_prompt(pos, srch_pos); @@ -63,6 +63,7 @@ static void ft_modify_str(char *str_srch, size_t srch_pos, char **str, ft_get_next_str(*str, pos); } free(str_srch); + return (0); } int ft_surch_in_history(char **str, size_t *pos) @@ -79,9 +80,8 @@ int ft_surch_in_history(char **str, size_t *pos) ft_give_new_prompt(str_srch, srch_pos); ret = 0; read(0, &ret, sizeof(int)); - if (ft_isprint(ret) && - ft_surch_and_realloc(str, &str_srch, ret, &srch_pos) < 0) - return (-1); + if (ft_isprint(ret) && search(str, &str_srch, ret, &srch_pos) < 0) + return (-1); else if (!ft_isprint(ret) && ret == 127 && srch_pos) { --srch_pos; @@ -92,6 +92,5 @@ int ft_surch_in_history(char **str, size_t *pos) else if (ret != 127 && !ft_isprint(ret)) break ; } - ft_modify_str(str_srch, srch_pos, str, pos); - return (0); + return (ft_modify_str(str_srch, srch_pos, str, pos)); } diff --git a/42sh/src/job_control/builtin_fg.c b/42sh/src/job_control/builtin_fg.c index 0201de78..dfbe6104 100644 --- a/42sh/src/job_control/builtin_fg.c +++ b/42sh/src/job_control/builtin_fg.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/08 14:30:07 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:00:49 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:12:16 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -37,7 +37,6 @@ int builtin_fg(const char *path, char *const av[], char *const envp[]) } else { - DG("rank:%i:%i", rank[0], rank[1]); if ((jlist = ft_lst_find(jobc->first_job, &rank[0], job_cmp_id))) job_run(jlist->content, 1); else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id))) diff --git a/42sh/src/job_control/builtin_jobs.c b/42sh/src/job_control/builtin_jobs.c index 3031cde0..dbae9068 100644 --- a/42sh/src/job_control/builtin_jobs.c +++ b/42sh/src/job_control/builtin_jobs.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 17:43:01 by jhalford #+# #+# */ -/* Updated: 2017/03/08 18:52:24 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:47:48 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/do_job_notification.c b/42sh/src/job_control/do_job_notification.c index 8bec9af4..a86208a8 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/03/18 00:07:12 by wescande ### ########.fr */ +/* Updated: 2017/03/20 12:15:50 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -27,8 +27,7 @@ int do_job_notification(void) { j = jlist->content; jlist = jlist->next; - if (job_is_completed(j->id) - || (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED))) + if ((job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED))) { ret = 1; job_notify_change(j->id); diff --git a/42sh/src/job_control/job_addprocess.c b/42sh/src/job_control/job_addprocess.c index 02181cb8..a72895c0 100644 --- a/42sh/src/job_control/job_addprocess.c +++ b/42sh/src/job_control/job_addprocess.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 13:54:51 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:57:09 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:32:08 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_free.c b/42sh/src/job_control/job_free.c index 7046cfe7..027c1676 100644 --- a/42sh/src/job_control/job_free.c +++ b/42sh/src/job_control/job_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/01/09 13:22:16 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:39:38 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_kill_all.c b/42sh/src/job_control/job_hup_all.c similarity index 78% rename from 42sh/src/job_control/job_kill_all.c rename to 42sh/src/job_control/job_hup_all.c index ded01abd..0a4e238c 100644 --- a/42sh/src/job_control/job_kill_all.c +++ b/42sh/src/job_control/job_hup_all.c @@ -1,18 +1,18 @@ /* ************************************************************************** */ /* */ /* ::: :::::::: */ -/* job_kill_all.c :+: :+: :+: */ +/* job_hup_all.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ -/* Created: 2017/01/08 15:36:56 by jhalford #+# #+# */ -/* Updated: 2017/01/09 16:35:51 by jhalford ### ########.fr */ +/* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */ +/* Updated: 2017/03/20 11:37:53 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ #include "minishell.h" -void job_kill_all(void) +void job_hup_all(void) { t_jobc *jobc; t_list *jlist; @@ -23,7 +23,7 @@ void job_kill_all(void) while (jlist) { job = jlist->content; - kill(-job->pgid, SIGKILL); + kill(-job->pgid, SIGHUP); jlist = jlist->next; } } diff --git a/42sh/src/job_control/job_is_completed.c b/42sh/src/job_control/job_is_completed.c index 83bc6ecb..aa20bece 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/03/20 11:10:14 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:30:44 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_is_stopped.c b/42sh/src/job_control/job_is_stopped.c index 45c0cb64..8d342c0f 100644 --- a/42sh/src/job_control/job_is_stopped.c +++ b/42sh/src/job_control/job_is_stopped.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/13 15:06:45 by jhalford #+# #+# */ -/* Updated: 2017/03/20 11:10:12 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:32:00 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ @@ -25,8 +25,8 @@ int job_is_stopped(int id) while (lst) { p = lst->content; - if (!(p->state == PROCESS_COMPLETED) - || !(p->state == PROCESS_SUSPENDED)) + if (!((p->state == PROCESS_COMPLETED) + || !(p->state == PROCESS_SUSPENDED))) return (0); lst = lst->next; } diff --git a/42sh/src/job_control/job_remove.c b/42sh/src/job_control/job_remove.c index 782aa632..e054c5c3 100644 --- a/42sh/src/job_control/job_remove.c +++ b/42sh/src/job_control/job_remove.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:51:08 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:20:57 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:40:09 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/job_update_status.c b/42sh/src/job_control/job_update_status.c index 7fca5ea1..c518decb 100644 --- a/42sh/src/job_control/job_update_status.c +++ b/42sh/src/job_control/job_update_status.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 12:56:11 by jhalford #+# #+# */ -/* Updated: 2017/03/16 18:32:15 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 12:12:45 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/mark_job_as_running.c b/42sh/src/job_control/mark_job_as_running.c index eb4b8623..0cf46b23 100644 --- a/42sh/src/job_control/mark_job_as_running.c +++ b/42sh/src/job_control/mark_job_as_running.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/08 14:40:40 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:56:42 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:33:55 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/process_format.c b/42sh/src/job_control/process_format.c index d6e54143..7fce0c80 100644 --- a/42sh/src/job_control/process_format.c +++ b/42sh/src/job_control/process_format.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2017/01/09 13:05:55 by jhalford #+# #+# */ -/* Updated: 2017/03/20 10:54:51 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:47:49 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/job_control/process_free.c b/42sh/src/job_control/process_free.c index 13e6aae7..29fab3f4 100644 --- a/42sh/src/job_control/process_free.c +++ b/42sh/src/job_control/process_free.c @@ -6,7 +6,7 @@ /* By: jhalford +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/12 12:41:11 by jhalford #+# #+# */ -/* Updated: 2017/03/16 16:53:06 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:39:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */ diff --git a/42sh/src/line_editing/readline.c b/42sh/src/line_editing/readline.c index 4bb37745..6205bbc9 100644 --- a/42sh/src/line_editing/readline.c +++ b/42sh/src/line_editing/readline.c @@ -6,7 +6,7 @@ /* By: gwojda +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2016/12/15 14:19:48 by gwojda #+# #+# */ -/* Updated: 2017/03/20 09:57:09 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 14:16:03 by gwojda ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,7 +19,11 @@ int readline(int has_prompt, char **input) if (!has_prompt) data_singleton()->line.prompt_size = 1; if (!SH_IS_INTERACTIVE(data_singleton()->opts)) - return ((ret = get_next_line(data_singleton()->fd, input)) >= 0 ? !ret : ret); + { + if ((ret = get_next_line(data_singleton()->fd, input)) >= 0) + return (!ret); + return (ret); + } readline_init(has_prompt); ret = ft_read_stdin(input); if (ret < 0) @@ -30,6 +34,7 @@ int readline(int has_prompt, char **input) ft_putchar('\n'); if (has_prompt) ret = ft_history_parsing(has_prompt, input); + ft_strdel(&data_singleton()->line.copy_tmp); if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1) return (-1); return (ret); diff --git a/42sh/src/main/shell_init.c b/42sh/src/main/shell_init.c index fcfb4611..5e1af3c5 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/03/20 11:30:08 by jhalford ### ########.fr */ +/* Updated: 2017/03/20 11:30:42 by jhalford ### ########.fr */ /* */ /* ************************************************************************** */