added getsemid
This commit is contained in:
parent
cdc14ee0e7
commit
dddb1d3b53
22
src/server.c
22
src/server.c
|
@ -2,8 +2,13 @@
|
|||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <server.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <errExit.h>
|
||||
#include <structures.h>
|
||||
|
||||
input_server_t check_input(int argc, char *argv[]){
|
||||
if (argc < 5) {
|
||||
|
@ -34,4 +39,21 @@ input_server_t check_input(int argc, char *argv[]){
|
|||
}
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
int getSemid(){
|
||||
int semid = semget(IPC_PRIVATE, 4, S_IRUSR | S_IWUSR);
|
||||
if (semid == -1) {
|
||||
errExit("semget", "getSemid");
|
||||
}
|
||||
|
||||
int val[] = {0, 0, 0, 0};
|
||||
union semun arg;
|
||||
arg.array = val;
|
||||
|
||||
if (semctl(semid, 0 , SETALL, arg) == -1) {
|
||||
errExit("semctl", "getSemid");
|
||||
}
|
||||
|
||||
return semid;
|
||||
}
|
Loading…
Reference in New Issue