Hi,
I am trying to implement a blocked or synchronous method of message passing using signal interrupts. So far I have the following:
server.c
{
msgget(queue)
msgrcv (queue mtype)
while(data to send) {
msgsnd(data)
kill(client, SIGUSR1)
}
close queue
}
client.c
{
sigaction(catch SIGUSR1)
msgget(queue)
msgsnd(queue mtype)
while(data to read) {
pause()
printf(dadta)
}
}
The way I can think of doing this is using sa_handler to call a function that reads from the queue when the signal is received. I feel like this isn't the best way to do it since I would have to globally define the structure that gets the data, along with the message queue id returned from msgget too.
I am trying to learn how to use signals better and I would like some pointers on how to do this, or ideas that I can try.
Thanks
I am trying to implement a blocked or synchronous method of message passing using signal interrupts. So far I have the following:
server.c
{
msgget(queue)
msgrcv (queue mtype)
while(data to send) {
msgsnd(data)
kill(client, SIGUSR1)
}
close queue
}
client.c
{
sigaction(catch SIGUSR1)
msgget(queue)
msgsnd(queue mtype)
while(data to read) {
pause()
printf(dadta)
}
}
The way I can think of doing this is using sa_handler to call a function that reads from the queue when the signal is received. I feel like this isn't the best way to do it since I would have to globally define the structure that gets the data, along with the message queue id returned from msgget too.
I am trying to learn how to use signals better and I would like some pointers on how to do this, or ideas that I can try.
Thanks
Comment