gonna add processes inside of job

This commit is contained in:
Jack Halford 2016-12-12 23:56:05 +01:00
parent 6cfac2eaff
commit 87b9fab083
5 changed files with 24 additions and 11 deletions

View file

@ -23,9 +23,6 @@ typedef long long t_type;
struct s_exec struct s_exec
{ {
int fdin;
int fdout;
int amp;
char *aol_status; char *aol_status;
int aol_search; int aol_search;
}; };

View file

@ -18,18 +18,33 @@
# include "libft.h" # include "libft.h"
typedef struct s_job t_job; typedef struct s_job t_job;
typedef struct s_process t_process;
typedef struct s_jobc t_jobc; typedef struct s_jobc t_jobc;
struct s_job struct s_job
{ {
int id; int id;
pid_t pid; pid_t pgid;
char notified;
char *command; char *command;
int foreground;
t_list *first_process;
};
struct s_process
{
char **argv;
pid_t pid;
int fdin;
int fdout;
char completed;
char stopped;
int status;
}; };
struct s_jobc struct s_jobc
{ {
t_list *list; t_list *first_job;
pid_t shell_pgid; pid_t shell_pgid;
int current_id; int current_id;
int rank[2]; int rank[2];

View file

@ -14,9 +14,9 @@
int exec_ampersand(t_btree **ast) int exec_ampersand(t_btree **ast)
{ {
data_singleton()->exec.amp = 1; data_singleton()->exec.foreground = 1;
ft_exec(&(*ast)->left); ft_exec(&(*ast)->left);
data_singleton()->exec.amp = 0; data_singleton()->exec.foreground = 0;
ft_exec(&(*ast)->right); ft_exec(&(*ast)->right);
btree_delone(ast, &ast_free); btree_delone(ast, &ast_free);
return (0); return (0);

View file

@ -55,7 +55,7 @@ int ft_cmd_exec(char *execpath, char **argv)
{ {
ft_strdel(&execpath); ft_strdel(&execpath);
g_pid = pid; g_pid = pid;
if (data_singleton()->exec.amp) if (data_singleton()->exec.foreground)
job_new(argv, pid); job_new(argv, pid);
else if (data_singleton()->exec.fdout == STDOUT) else if (data_singleton()->exec.fdout == STDOUT)
{ {

View file

@ -14,8 +14,9 @@
t_parser g_parser[] = t_parser g_parser[] =
{ {
{TK_SEMI | TK_AMP, &parse_separator}, {TK_SEMI, &parse_separator},
{TK_AND_IF | TK_OR_IF, &parse_separator}, {TK_AND_IF | TK_OR_IF, &parse_separator},
{TK_AMP, &parse_separator},
{TK_PIPE, &parse_separator}, {TK_PIPE, &parse_separator},
{TK_LESS, &parse_less}, {TK_LESS, &parse_less},
{TK_GREAT, &parse_great}, {TK_GREAT, &parse_great},