job control: retrieval of dat as a global g_data so signal handlers can access it
This commit is contained in:
parent
4cfeb62747
commit
09e823bf2b
8 changed files with 31 additions and 11 deletions
|
|
@ -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: 2016/12/10 17:36:55 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 18:20:40 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,7 +24,13 @@ struct s_job
|
||||||
char *command;
|
char *command;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern t_data *g_data;
|
||||||
|
|
||||||
void job_new(t_data *data, char **av, pid_t pid);
|
void job_new(t_data *data, char **av, pid_t pid);
|
||||||
void job_announce(t_job *job);
|
void job_announce(t_job *job);
|
||||||
|
|
||||||
|
void sigchld_handler(int signo);
|
||||||
|
void sigint_handler(int signo);
|
||||||
|
void sigtstp_handler(int signo);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
/* Created: 2016/11/10 13:07:44 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/10 17:12:35 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 17:56:39 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -76,8 +76,6 @@ typedef enum e_qstate t_qstate;
|
||||||
extern t_stof g_builtins[];
|
extern t_stof g_builtins[];
|
||||||
extern pid_t g_pid;
|
extern pid_t g_pid;
|
||||||
|
|
||||||
void sigint_handler(int signo);
|
|
||||||
void sigstop_handler(int signo);
|
|
||||||
int data_init(t_data *data);
|
int data_init(t_data *data);
|
||||||
void data_exit(t_data *data);
|
void data_exit(t_data *data);
|
||||||
void ft_cleanup(void);
|
void ft_cleanup(void);
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 97bc4fed552dce523e2de8fb744ba46ec877f8eb
|
Subproject commit 42e1a190bd86ea288ee9a367fefeac8284a67cf4
|
||||||
|
|
@ -6,13 +6,13 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 16:51:54 by jhalford #+# #+# */
|
/* Created: 2016/12/10 16:51:54 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/10 17:37:33 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 17:58:04 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "job_control.h"
|
#include "job_control.h"
|
||||||
|
|
||||||
void job_new(t_data *data, char **av, pid_t pid, t_type type)
|
void job_new(t_data *data, char **av, pid_t pid)
|
||||||
{
|
{
|
||||||
t_job job;
|
t_job job;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,26 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 17:37:56 by jhalford #+# #+# */
|
/* Created: 2016/12/10 17:37:56 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/10 17:46:12 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 18:25:01 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
|
t_data *g_data;
|
||||||
|
|
||||||
void sigchld_handler(int signo)
|
void sigchld_handler(int signo)
|
||||||
{
|
{
|
||||||
|
t_job *job;
|
||||||
|
t_list *list;
|
||||||
|
|
||||||
(void)signo;
|
(void)signo;
|
||||||
DG("got SIGCHLD");
|
DG("got SIGCHLD");
|
||||||
|
list = g_data->jobc.list;
|
||||||
|
if (list)
|
||||||
|
job = list->content;
|
||||||
|
else
|
||||||
|
job = NULL;
|
||||||
|
if (job)
|
||||||
|
DG("job pid=%i", job->pid);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
|
/* Created: 2016/12/10 15:14:53 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/10 17:46:16 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 18:20:57 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
/* Created: 2016/11/28 19:26:32 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/10 17:35:16 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 17:58:36 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -39,5 +39,6 @@ int data_init(t_data *data)
|
||||||
if (signal(SIGTSTP, sigtstp_handler) == SIG_ERR)
|
if (signal(SIGTSTP, sigtstp_handler) == SIG_ERR)
|
||||||
ft_dprintf(STDERR, "\ncan't catch SIGTSTP\n");
|
ft_dprintf(STDERR, "\ncan't catch SIGTSTP\n");
|
||||||
if (signal(SIGCHLD, sigchld_handler) == SIG_ERR)
|
if (signal(SIGCHLD, sigchld_handler) == SIG_ERR)
|
||||||
|
ft_dprintf(STDERR, "\ncan't catch SIGCHLD\n");
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,14 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
/* Created: 2016/12/06 18:40:58 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/10 17:16:19 by jhalford ### ########.fr */
|
/* Updated: 2016/12/10 17:58:39 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "minishell.h"
|
#include "minishell.h"
|
||||||
|
|
||||||
|
t_data *g_data;
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
t_data data;
|
t_data data;
|
||||||
|
|
@ -20,6 +22,7 @@ int main(void)
|
||||||
|
|
||||||
token = NULL;
|
token = NULL;
|
||||||
ast = NULL;
|
ast = NULL;
|
||||||
|
g_data = &data;
|
||||||
if (data_init(&data))
|
if (data_init(&data))
|
||||||
return (1);
|
return (1);
|
||||||
DG("{inv}{bol}{gre}start of shell");
|
DG("{inv}{bol}{gre}start of shell");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue