This commit is contained in:
wescande 2017-03-20 14:47:03 +01:00
commit f8753646e2
36 changed files with 118 additions and 109 deletions

View file

@ -180,9 +180,9 @@ job_control/job_format_head.c\
job_control/job_free.c\ job_control/job_free.c\
job_control/job_getprocess.c\ job_control/job_getprocess.c\
job_control/job_getrank.c\ job_control/job_getrank.c\
job_control/job_hup_all.c\
job_control/job_is_completed.c\ job_control/job_is_completed.c\
job_control/job_is_stopped.c\ job_control/job_is_stopped.c\
job_control/job_kill_all.c\
job_control/job_notify_change.c\ job_control/job_notify_change.c\
job_control/job_notify_new.c\ job_control/job_notify_new.c\
job_control/job_remove.c\ job_control/job_remove.c\

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* builtin_read.h :+: :+: :+: */ /* builtin_read.h :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 15:02:39 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 struct s_read
{ {
t_flag opts; t_flag opts;
char **names; char **names;
char delim; char delim;
int nchars; int nchars;
char *prompt; char *prompt;
int timeout; int timeout;
int fd; int fd;
char *input; 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); int bt_read_init(t_read *data, char **av);

View file

@ -6,7 +6,7 @@
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */ /* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/08 16:34:51 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 ** Cursor data : cursor's coordonate and windows size
*/ */
struct s_curs struct s_curs
{ {
int co; int co;
int li; 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_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(t_curs *curs, char *str, size_t len);
void curs_video_write_static( void curs_video_write_static(
t_curs *curs, char *str, size_t len); t_curs *curs, char *str, size_t len);
#endif #endif

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/23 10:35:44 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 CORRUPT 1
//# define STR data_singleton()->line.input
//# define POS data_singleton()->line.pos
# define ERROR_CNTL_R 1 # define ERROR_CNTL_R 1
typedef struct s_list_history typedef struct s_list_history

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/10 16:55:09 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); int job_wait(int id);
void job_remove(int id); void job_remove(int id);
void job_free(void *content, size_t content_size); 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_foreground(t_job *job, int cont);
int put_job_in_background(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 ** Mapping pour afficher les process
*/ */
void pprint(t_process *p); 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_brace(t_process *p);
int pprint_while(t_process *p); int pprint_while(t_process *p);
int pprint_if(t_process *p); int pprint_if(t_process *p);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/01 12:15:50 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; int type;
}; };
extern t_rvwords g_rvwords[]; /* extern t_rvwords g_rvwords[]; */
/* extern int (*g_lexer[])(t_list **alst, t_lexer *lexer); */
extern int (*g_lexer[])(t_list **alst, t_lexer *lexer);
int ft_post_tokenize(t_list **alst, char **str); int ft_post_tokenize(t_list **alst, char **str);

View file

@ -94,8 +94,6 @@ struct s_treematch
int (*add)(t_btree **ast, t_list **lst); int (*add)(t_btree **ast, t_list **lst);
}; };
extern t_treematch g_treematch[];
int build_tree(t_btree **ast, t_list **lst); int build_tree(t_btree **ast, t_list **lst);
int add_sep(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); 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 struct s_redir
{ {

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:57:21 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) if (!lst)
return (NULL); 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); elem->next = ft_lstmap(lst->next, f);
return (elem); return (elem);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/29 15:57:38 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* id.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/20 12:20:59 by jhalford #+# #+# */
/* Updated: 2017/03/20 12:21:01 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h" #include "libft.h"
void *id(void *data) void *id(void *data)

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* bt_read_term.c :+: :+: :+: */ /* bt_read_term.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/25 16:02:05 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); return (term);
} }
int bt_read_terminit(t_read *data) int bt_read_terminit(t_read *data)
{ {
struct termios term; struct termios term;
@ -39,7 +39,7 @@ int bt_read_terminit(t_read *data)
return (0); return (0);
} }
int bt_read_exit(t_read *data) int bt_read_exit(t_read *data)
{ {
struct termios term; struct termios term;

View file

@ -6,14 +6,14 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:14:20 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" #include "minishell.h"
#define US_ENV "env [-i] [-u name] [name=value]... [utility [argument...]]" #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) if (arg_miss)
ft_dprintf(2, "{red}env: option requires an argument -- u{eoc}\n"); 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); return (1);
} }
static void env_freeone(char **env, char *arg) static void env_freeone(char **env, char *arg)
{ {
int i; int i;
char *tmp; 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; char **arg_split;
@ -58,7 +58,7 @@ static void env_replace(char ***custom_env, char *arg)
*custom_env = ft_sstradd(*custom_env, 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)) while (*(++*arg))
{ {

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 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) if (SH_HAS_JOBC(data_singleton()->opts) && jlist && !notified)
{ {
notified = 1; 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); return (0);
} }
if (av && av[1]) status = (av && av[1]) ?
status = ft_atoi(av[1]); ft_atoi(av[1]) : ft_atoi(ft_getenv(data_singleton()->env, "?"));
else
status = ft_atoi(ft_getenv(data_singleton()->env, "?"));
if (SH_IS_INTERACTIVE(data_singleton()->opts)) if (SH_IS_INTERACTIVE(data_singleton()->opts))
tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes); tcsetattr(STDIN, TCSANOW, &data_singleton()->jobc.shell_tmodes);
job_hup_all();
data_exit(); data_exit();
exit(status); exit(status);
return (0); return (0);

View file

@ -6,13 +6,13 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/15 11:39:37 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" #include "minishell.h"
static t_cliopts export_opts[] = static t_cliopts g_export_opts[] =
{ {
{'p', NULL, BT_EXPORT_LP, 0, NULL}, {'p', NULL, BT_EXPORT_LP, 0, NULL},
{0, NULL, 0, 0, NULL}, {0, NULL, 0, 0, NULL},
@ -44,23 +44,20 @@ int builtin_export(
(void)envp; (void)envp;
(void)path; (void)path;
data.flag = 0; data.flag = 0;
if (cliopts_get((char**)av, export_opts, &data)) if (cliopts_get((char**)av, g_export_opts, &data))
ft_perror(); ft_perror();
if (data.flag & BT_EXPORT_LP) if (data.flag & BT_EXPORT_LP)
return (builtin_return_status(0, bt_export_print())); return (builtin_return_status(0, bt_export_print()));
av = data.av_data; av = data.av_data;
while (*av) while (*av)
{ {
if ((equal = ft_strchr(*av, '='))) equal = ft_strchr(*av, '=');
{ if (equal)
*equal = 0; *equal = 0;
builtin_setenv("internal", (char*[]){"global", *av, equal + 1}, NULL);
}
else else
{
equal = ft_getenv(data_singleton()->local_var, *av); 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); builtin_unsetenv("internal", (char*[]){"local", *av, NULL}, NULL);
av++; av++;
} }

View file

@ -6,17 +6,17 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/17 18:54:00 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" #include "minishell.h"
# define MATHERR_0 "math : invalid number of arguments\n" #define MATHERR_0 "math : invalid number of arguments\n"
# define MATHERR_1 "math : invalid variable name\n" #define MATHERR_1 "math : invalid variable name\n"
# define MATHERR_2 "math : invalid operator\n" #define MATHERR_2 "math : invalid operator\n"
# define MATHERR_3 "math : invalid operand\n" #define MATHERR_3 "math : invalid operand\n"
# define MATHERR_4 "math : division by 0\n" #define MATHERR_4 "math : division by 0\n"
static int error_msg(char *msg) static int error_msg(char *msg)
{ {
@ -38,7 +38,7 @@ static int get_value(char *var, char **value)
{ {
char *temp; char *temp;
char *esc; char *esc;
int ret; int ret;
esc = ft_strnew((ft_strlen(var) >> 3) + 1); esc = ft_strnew((ft_strlen(var) >> 3) + 1);
ret = word_is_assignment((char *[]) {var, (esc + 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))); return (builtin_return_status(0, error_msg(MATHERR_3)));
if (do_math(&value, operator, operand)) if (do_math(&value, operator, operand))
return (builtin_return_status(0, 1)); 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)); return (builtin_return_status(0, 0));
} }

View file

@ -3,10 +3,10 @@
/* ::: :::::::: */ /* ::: :::::::: */
/* builtin_read.c :+: :+: :+: */ /* builtin_read.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/20 15:01:45 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->timeout = 0;
data->input = NULL; data->input = NULL;
if ((cliopts_get(av, g_read_opts, data))) if ((cliopts_get(av, g_read_opts, data)))
return(ft_perror() ? 2 : 2); return (ft_perror() ? 2 : 2);
if (bt_read_terminit(data) < 0) if (bt_read_terminit(data) < 0)
return (-1); return (-1);
return (0); return (0);
} }
int bt_read_loop(t_read *data) int bt_read_loop(t_read *data)
{ {
int i; int i;
int esc; int esc;
@ -75,7 +75,7 @@ int bt_read_loop(t_read *data)
return (0); return (0);
} }
int bt_read_assign(t_read *data) int bt_read_assign(t_read *data)
{ {
char *input; char *input;
char **names; char **names;
@ -98,7 +98,7 @@ int bt_read_assign(t_read *data)
return (0); 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; t_read data;
int ret; int ret;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 14:31:42 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->attrs = 0;
exec->job.id = 0; exec->job.id = 0;
exec->job.pgid = 0; exec->job.pgid = 0;
exec->job.attrs = 0; exec->job.attrs = JOB_NOTIFIED;
exec->job.first_process = NULL; exec->job.first_process = NULL;
tcgetattr(STDIN, &exec->job.tmodes); tcgetattr(STDIN, &exec->job.tmodes);
jobc->first_job = NULL; jobc->first_job = NULL;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/08 00:02:58 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */ /* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/03 18:12:57 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/26 10:43:16 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"); 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) int ret, size_t *srch_pos)
{ {
if (!(*str_srch = ft_realloc_imput(*str_srch, ret, *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) size_t *pos)
{ {
ft_clear_prompt(pos, srch_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); ft_get_next_str(*str, pos);
} }
free(str_srch); free(str_srch);
return (0);
} }
int ft_surch_in_history(char **str, size_t *pos) 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); ft_give_new_prompt(str_srch, srch_pos);
ret = 0; ret = 0;
read(0, &ret, sizeof(int)); read(0, &ret, sizeof(int));
if (ft_isprint(ret) && if (ft_isprint(ret) && search(str, &str_srch, ret, &srch_pos) < 0)
ft_surch_and_realloc(str, &str_srch, ret, &srch_pos) < 0) return (-1);
return (-1);
else if (!ft_isprint(ret) && ret == 127 && srch_pos) else if (!ft_isprint(ret) && ret == 127 && srch_pos)
{ {
--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)) else if (ret != 127 && !ft_isprint(ret))
break ; break ;
} }
ft_modify_str(str_srch, srch_pos, str, pos); return (ft_modify_str(str_srch, srch_pos, str, pos));
return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 14:30:07 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 else
{ {
DG("rank:%i:%i", rank[0], rank[1]);
if ((jlist = ft_lst_find(jobc->first_job, &rank[0], job_cmp_id))) if ((jlist = ft_lst_find(jobc->first_job, &rank[0], job_cmp_id)))
job_run(jlist->content, 1); job_run(jlist->content, 1);
else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id))) else if ((jlist = ft_lst_find(jobc->first_job, &rank[1], job_cmp_id)))

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 17:43:01 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 13:01:19 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; j = jlist->content;
jlist = jlist->next; jlist = jlist->next;
if (job_is_completed(j->id) if ((job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED)))
|| (job_is_stopped(j->id) && !(j->attrs & JOB_NOTIFIED)))
{ {
ret = 1; ret = 1;
job_notify_change(j->id); job_notify_change(j->id);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 13:54:51 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -1,18 +1,18 @@
/* ************************************************************************** */ /* ************************************************************************** */
/* */ /* */
/* ::: :::::::: */ /* ::: :::::::: */
/* job_kill_all.c :+: :+: :+: */ /* job_hup_all.c :+: :+: :+: */
/* +:+ +:+ +:+ */ /* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 15:36:56 by jhalford #+# #+# */ /* Created: 2017/03/20 11:37:40 by jhalford #+# #+# */
/* Updated: 2017/01/09 16:35:51 by jhalford ### ########.fr */ /* Updated: 2017/03/20 11:37:53 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#include "minishell.h" #include "minishell.h"
void job_kill_all(void) void job_hup_all(void)
{ {
t_jobc *jobc; t_jobc *jobc;
t_list *jlist; t_list *jlist;
@ -23,7 +23,7 @@ void job_kill_all(void)
while (jlist) while (jlist)
{ {
job = jlist->content; job = jlist->content;
kill(-job->pgid, SIGKILL); kill(-job->pgid, SIGHUP);
jlist = jlist->next; jlist = jlist->next;
} }
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 15:10:20 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/13 15:06:45 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) while (lst)
{ {
p = lst->content; p = lst->content;
if (!(p->state == PROCESS_COMPLETED) if (!((p->state == PROCESS_COMPLETED)
|| !(p->state == PROCESS_SUSPENDED)) || !(p->state == PROCESS_SUSPENDED)))
return (0); return (0);
lst = lst->next; lst = lst->next;
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 12:51:08 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 12:56:11 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/08 14:40:40 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/09 13:05:55 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */ /* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 12:41:11 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */ /* By: gwojda <gwojda@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/15 14:19:48 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) if (!has_prompt)
data_singleton()->line.prompt_size = 1; data_singleton()->line.prompt_size = 1;
if (!SH_IS_INTERACTIVE(data_singleton()->opts)) 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); readline_init(has_prompt);
ret = ft_read_stdin(input); ret = ft_read_stdin(input);
if (ret < 0) if (ret < 0)
@ -30,6 +34,7 @@ int readline(int has_prompt, char **input)
ft_putchar('\n'); ft_putchar('\n');
if (has_prompt) if (has_prompt)
ret = ft_history_parsing(has_prompt, input); ret = ft_history_parsing(has_prompt, input);
ft_strdel(&data_singleton()->line.copy_tmp);
if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1) if (tcsetattr(0, TCSANOW, ft_save_termios(0)) == -1)
return (-1); return (-1);
return (ret); return (ret);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */ /* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/12 17:23:59 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 */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */