concatenation marche

This commit is contained in:
Laureηt 2021-04-21 14:01:28 +02:00
parent 37451f22b7
commit 4b500002f6
5 changed files with 15 additions and 14 deletions

BIN
jobs

Binary file not shown.

22
jobs.c
View file

@ -3,24 +3,26 @@
#include <string.h>
#include "jobs.h"
void ajouter(list *l_ptr, int pid, int id, char*** cmd)
void ajouter(list *l_ptr, int pid, int id, char** seq)
{
cell *new_cell = malloc(sizeof(*new_cell));
cell* new_cell = malloc(sizeof(*new_cell));
char *name_with_extension;
name_with_extension = malloc(sizeof(char)*256);
char** cursor = *cmd;
char* cmd;
cmd = malloc(sizeof(char)*256);
cmd[0] = '\0';
strcpy(name_with_extension, *cursor);
cursor++;
strcat(name_with_extension, *cursor);
cursor++;
char* test = *cursor;
while (*seq)
{
strcat(cmd, *seq);
seq++;
strcat(cmd, " ");
}
new_cell->pid = pid;
new_cell->id = id;
new_cell->cmd = cmd;
if (*l_ptr == NULL)
{

2
jobs.h
View file

@ -11,7 +11,7 @@ struct cell {
typedef cell* list;
void ajouter(cell** list, int pid, int id, char*** cmd);
void ajouter(cell** list, int pid, int id, char** cmd);
void supprimer(cell** list, int pid);
void afficher(cell** list);
void initialiser(list* list);

BIN
minishell

Binary file not shown.

View file

@ -90,7 +90,6 @@ int main(int argc, char *argv[])
}
getcwd(currentcd, 256);
printf("%s >>> ", currentcd);
prompting = 1;
@ -159,7 +158,7 @@ int main(int argc, char *argv[])
{ // instructions du père
if (cmd->backgrounded)
{ // on sauvegarde le pid, si background
ajouter(&jobs, pidFils, job_id++, cmd->seq);
ajouter(&jobs, pidFils, job_id++, *(cmd->seq));
}
else
{ // on attend le fils, si foreground