Skip to content

Commit

Permalink
Started job command
Browse files Browse the repository at this point in the history
  • Loading branch information
Biscuitmunch committed Mar 29, 2022
1 parent d4f0dd6 commit 311d062
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ash.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,17 @@ char ***createPipeArgInput(char **userArgs, int amper, char *constantFullCommand
executeWithPipes(pipedArgs, amper, maxPipes, constantFullCommand, jobCommandsAmper, jobIDs);
}

void jobCommand(uid_t *jobIDs, char **jobCommandsAmper)
{
for (int i = 1; i <= processCounter; i++)
{
if (jobIDs[i] != 0)
{
printf("[%d] %d %s\n", i, jobIDs[i], jobCommandsAmper[i]);
}
}
}

void runCommand(char **userArgs, char *constantFullCommand, char *OGdirectory,
char **historyCommands, char **jobCommandsAmper, pid_t *jobIDs)
{
Expand Down Expand Up @@ -445,6 +456,12 @@ void runCommand(char **userArgs, char *constantFullCommand, char *OGdirectory,
historyCommand(userArgs[1], historyCommands, OGdirectory, jobCommandsAmper, jobIDs);
}

// If command is jobs
if (strcmp(userArgs[0], "jobs") == 0)
{
jobCommand(jobIDs, jobCommandsAmper);
}

// Run built-in normal commands
else
{
Expand Down

0 comments on commit 311d062

Please sign in to comment.