-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexec_reminder.c
More file actions
33 lines (33 loc) · 827 Bytes
/
exec_reminder.c
File metadata and controls
33 lines (33 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include "custom_header.h"
int exec_reminder(char *cmd)
{
pid_t pid,wpid;
//background is defined when last argument is &
char ** argv = argumentize(cmd);
int argc = argCount(argv);
int waitDuration = atoi(argv[1]);
pid = fork();
if(pid<0)
{
//fork error
perror("It's PK's Shell");
_exit(1);
}
else if(!pid)
{
//child process should call execvp
int check = sleep(waitDuration);
if(check<0)
{
perror("It's PK's Shell");
//If not killed multiple copies of shell would open
_exit(1);
}
printf("\nIts_PKS_Shell:\t REMINDER:");
for(int i=2;i<argc;i++)
printf("%s ",argv[i]);
printf("\nPress enter to continue");
_exit(1);
}
return 0;
}