-
Notifications
You must be signed in to change notification settings - Fork 0
/
manager.h
68 lines (54 loc) · 1.48 KB
/
manager.h
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
60
61
62
63
64
65
66
67
68
#ifndef MANAGER_H_
#define MANAGER_H_
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/shm.h>
#include <iostream>
#include <deque>
#include <algorithm>
using namespace std;
/*********************** Manager's handlers ******************/
void sig_handler(int signum){
printf("-- Inside a handler// Stop the prorgam now! Kill your childs now\n");
signal(SIGCHLD, sig_handler);
}
/***********************************************************/
// Manager write to the pipe.
void manager_messege(char* file_name, int manager_read, int fd1){
//printf("manager write to the pipe now!!!!\n");
if (write(fd1, file_name, manager_read) != manager_read){
perror("manager: write error");
}
if(manager_read < 0)
perror("manager: error!");
}
/************* Deque ***************/
void showdq(deque<char*> g){
deque<char*>::iterator it;
for (it = g.begin(); it != g.end(); ++it)
cout << '\t' << *it;
cout << '\n';
}
void showdq2(deque<int> g){
deque<int>::iterator it;
for (it = g.begin(); it != g.end(); ++it)
cout << '\t' << *it;
cout << '\n';
}
/*******************************************************/
char * separeta(char* buff){
char s[2] = " ";
char* token;
char *old = buff;
/* get the first token */
token = strtok(buff, s);
/* walk through other tokens */
while( token != NULL ) {
strcpy(old, token);
token = strtok(NULL, s);
}
return old;
}
#endif