

Executable Code:
#include <signal.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>
#include <errno.h>
void hand_contr(int);
int shm_id,pid=0;
char * pshmatt=NULL;
int main()
{
signal(SIGINT,hand_contr);
// Create the segment
shm_id=shmget(100,200,IPC_CREAT|IPC_EXCL|0777);
// Attach the shared memory
pshmatt=shmat(shm_id,NULL,0);
while(1)
{
// Compare if it is "HI"
if(strcmp(pshmatt,"HI")==0)
{
printf("Greetings!\n");
fflush(stdout);
pshmatt[0]='\0';
}
// Compare if it is "PID"
else if(strcmp(pshmatt,"PID")==0)
{
// Get the id of process
pid=(int)getpid();
printf("Server pid: %i\n",pid);
fflush(stdout);
pshmatt[0]='\0';
}
// Compare if it is "QUIT"
else if(strcmp(pshmatt,"QUIT")==0)
{
shmctl(shm_id,IPC_RMID,NULL);
shmdt(pshmatt);
printf("GOODBYE!\n");
exit(0);
}
}
}
void hand_contr(int XYZ)
{
shmctl(shm_id,IPC_RMID,NULL);
shmdt(pshmatt);
printf("GOODBYE!\n");
exit(0);
}
Need help with this code in C Write your own simple client/server set of processes. The...
This is for a Unix class.
Please help me out.
I am attaching a skeletal code of the program below, it just
needs ti be filled in.
Below is a skeletal code of the program. Fork a child process and then use the
parent for reading and the child for writing. This is
just a way of sending and receiving messages
asynchronously.
/*
*************************************************************
* Utility functions
* **************************************************************
*/
static void
usageError(const char * progName, const char *msg)
{...