-
Notifications
You must be signed in to change notification settings - Fork 0
/
sighand.c
59 lines (55 loc) · 954 Bytes
/
sighand.c
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//libraries
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <signal.h>
#include <dirent.h>
#include <sys/dir.h>
#include <pwd.h>
#include <grp.h>
#include <time.h>
#include <locale.h>
#include<sys/utsname.h>
#include "declarations.h"
//ctrl c
void sigintHandler(int sig_num)
{
//printf ("\n");
//prompt();
fflush (stdout);
}
//ctrl z
void sigstpHandler(int sig_num)
{
if(pid!=0)
{
kill(pid,SIGSTOP);
maxbg++;
a[maxbg].pid=pid;
a[maxbg].jobid=maxbg;
strcpy(a[maxbg].command,cmd);
strcpy(a[maxbg].status,"Stopped");
a[maxbg].flag=0;
a[maxbg].state=1;
printf("[%d]+ %s\t\t%s\n",a[maxbg].jobid,a[maxbg].status,a[maxbg].command);
pid=0;
}
else
{
//printf ("\n");
//prompt();
fflush (stdout);
}
}
//ctrl '\'
void sigqHandler(int sig_num)
{
printf("\n");
prompt();
}