job control minor fixes

This commit is contained in:
Jack Halford 2017-03-20 11:49:00 +01:00
parent e3cea95575
commit 33f6c24b0e
17 changed files with 29 additions and 27 deletions

View file

@ -179,9 +179,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\

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/28 14:28:41 by jhalford #+# #+# */
/* Updated: 2017/03/18 15:41:42 by gwojda ### ########.fr */
/* Updated: 2017/03/20 11:37:51 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
@ -26,7 +26,8 @@ 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])
@ -35,6 +36,7 @@ int builtin_exit(const char *path, char *const av[], char *const envp[])
status = 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);

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/05 14:54:45 by jhalford #+# #+# */
/* Updated: 2017/03/20 10:57:06 by jhalford ### ########.fr */
/* Updated: 2017/03/20 11:38:35 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: ariard <ariard@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/03 18:12:57 by ariard #+# #+# */
/* Updated: 2017/03/18 18:59:57 by ariard ### ########.fr */
/* Updated: 2017/03/20 11:39:40 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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: jhalford <jhalford@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 */
/* */
/* ************************************************************************** */