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 <string.h>
|
||||||
#include "jobs.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);
|
while (*seq)
|
||||||
cursor++;
|
{
|
||||||
strcat(name_with_extension, *cursor);
|
strcat(cmd, *seq);
|
||||||
cursor++;
|
seq++;
|
||||||
char* test = *cursor;
|
strcat(cmd, " ");
|
||||||
|
}
|
||||||
|
|
||||||
new_cell->pid = pid;
|
new_cell->pid = pid;
|
||||||
new_cell->id = id;
|
new_cell->id = id;
|
||||||
|
new_cell->cmd = cmd;
|
||||||
|
|
||||||
if (*l_ptr == NULL)
|
if (*l_ptr == NULL)
|
||||||
{
|
{
|
||||||
|
|
2
jobs.h
2
jobs.h
|
@ -11,7 +11,7 @@ struct cell {
|
||||||
|
|
||||||
typedef cell* list;
|
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 supprimer(cell** list, int pid);
|
||||||
void afficher(cell** list);
|
void afficher(cell** list);
|
||||||
void initialiser(list* list);
|
void initialiser(list* list);
|
||||||
|
|
|
@ -90,7 +90,6 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
getcwd(currentcd, 256);
|
getcwd(currentcd, 256);
|
||||||
|
|
||||||
printf("%s >>> ", currentcd);
|
printf("%s >>> ", currentcd);
|
||||||
|
|
||||||
prompting = 1;
|
prompting = 1;
|
||||||
|
@ -159,7 +158,7 @@ int main(int argc, char *argv[])
|
||||||
{ // instructions du père
|
{ // instructions du père
|
||||||
if (cmd->backgrounded)
|
if (cmd->backgrounded)
|
||||||
{ // on sauvegarde le pid, si background
|
{ // on sauvegarde le pid, si background
|
||||||
ajouter(&jobs, pidFils, job_id++, cmd->seq);
|
ajouter(&jobs, pidFils, job_id++, *(cmd->seq));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // on attend le fils, si foreground
|
{ // on attend le fils, si foreground
|
||||||
|
|
Loading…
Reference in a new issue