-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
200 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
20 | ||
cd ./uwu/ | ||
|
||
quit | ||
clear | ||
quit | ||
cd .. | ||
cd OS | ||
ls | ||
cd u:x:0:0:root:/root:/bin/bash | ||
|
||
quit | ||
cd uwu | ||
cd .. | ||
OS | ||
cd OS | ||
cd ./uwu/ | ||
cd .. | ||
cat uwu | ||
date | ||
sleep 1 & | ||
|
||
jobs | ||
quit | ||
vim & | ||
sleep 1 & | ||
vim & | ||
jobs | ||
gf 5 | ||
vim & | ||
jwel | ||
vim & | ||
jobs | ||
fg 3 | ||
jobs | ||
fg 1 | ||
jobs | ||
fg 2 | ||
asbkdj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,84 @@ | ||
#include "headers.h" | ||
#include "functions.h" | ||
|
||
|
||
void jobs(char* command) | ||
void jobs(char *command) | ||
{ | ||
int jobs_r_flag = 0; | ||
int jobs_s_flag = 0; | ||
|
||
char * token = strtok(command," \t"); | ||
if(strcmp(token,"jobs") != 0) | ||
char *token = strtok(command, " \t"); | ||
if (strcmp(token, "jobs") != 0) | ||
{ | ||
if(debug) printf("Not a jobs command, Wrong number\n"); | ||
if (debug) | ||
printf("Not a jobs command, Wrong number\n"); | ||
} | ||
|
||
token = strtok(NULL," \t"); | ||
token = strtok(NULL, " \t"); | ||
|
||
while(token != NULL) | ||
while (token != NULL) | ||
{ | ||
if(!strcmp(token,"-r")) | ||
if (!strcmp(token, "-r")) | ||
{ | ||
jobs_r_flag = 1; | ||
} | ||
else if (!strcmp(token,"-s")) | ||
else if (!strcmp(token, "-s")) | ||
{ | ||
jobs_s_flag = 1; | ||
jobs_s_flag = 1; | ||
} | ||
else | ||
{ | ||
fprintf(stderr,"Too many arguements for jobs\n"); | ||
fprintf(stderr, "Too many arguements for jobs\n"); | ||
} | ||
} | ||
|
||
if((jobs_r_flag == 0) && (jobs_s_flag == 0)) | ||
if ((jobs_r_flag == 0) && (jobs_s_flag == 0)) | ||
{ | ||
jobs_r_flag = 1; | ||
jobs_s_flag = 1; | ||
} | ||
|
||
for(int i =0 ; i < bgpno; i++) | ||
char filePath[MY_LEN]; | ||
char statRead[MY_LEN]; | ||
|
||
// for(int i =0 ; i < bgpno; i++) | ||
// { | ||
// if(exists[i]) | ||
// { | ||
// printf("[%d] Running %s [%d]\n",i + 1,bgp[i],bgpid[i]); | ||
// } | ||
// else | ||
// { | ||
// printf("[%d] Stopped %s [%d]\n",i + 1,bgp[i],bgpid[i]); | ||
// } | ||
// } | ||
|
||
for (int i = 0; i < bgpno; i++) | ||
{ | ||
if(exists[i]) | ||
{ | ||
printf("[%d] Running %s [%d]\n",i + 1,bgp[i],bgpid[i]); | ||
} | ||
else | ||
char pidstring[MY_LEN]; | ||
sprintf(pidstring, "%d", bgpid[i]); | ||
|
||
if(bexists[i] == 0) continue; | ||
|
||
char pinfoPath[MY_LEN]; | ||
strcpy(pinfoPath, "/proc/"); | ||
strcat(pinfoPath, pidstring); | ||
strcat(pinfoPath, "/stat"); | ||
|
||
FILE* fp = fopen(pinfoPath, "r"); | ||
if (fp == NULL) | ||
{ | ||
printf("[%d] Stopped %s [%d]\n",i + 1,bgp[i],bgpid[i]); | ||
fprintf(stderr,"pid proc file doesnt exist\n"); | ||
return; | ||
} | ||
} | ||
|
||
char temp[MY_LEN]; | ||
fscanf(fp, "%s", temp); | ||
fscanf(fp, "%s", temp); | ||
fscanf(fp, "%s", temp); | ||
|
||
char processStatus[MY_LEN]; | ||
strcpy(processStatus, temp); | ||
|
||
printf("[%d] %s %s [%d]\n", i + 1, !strcmp(processStatus,"S") ? "Running" : "Stopped", bgp[i], bgpid[i]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.