concatenation marche
This commit is contained in:
parent
37451f22b7
commit
4b500002f6
22
jobs.c
22
jobs.c
|
@ -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
2
jobs.h
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue