minitalk
by bhagenlo
written for version 2
Hey there!
Welcome to my favourite project so far. It is nice, clean, and short, and you spend most of your time learning about stuff, not debugging some nasty piece of code with dubious pointer and memory errors in it.
I'm sure you'll like it, too :)
Okay: What do you need to start? But first things first. And the answer is: Via signals. You have two of them at your disposal: And once you've understood that, the only thing left is: And now that you've got a good idea about how you can do things, you should be good to go :)#Pre & During
The hard part about this project is, in my opinion, to know how to do what you have to do.
You have to build two seperate executables, a server
and a client
, which should communicate with each other. For that, the client should be able to send a message (a string) to its server.
Which brings us to the next question: How can two seperate processes interact in UNIX at all?SIGUSR1
and SIGUSR2
.
With those, you have to somehow encode the information you want to send.So, how could you encode information with only two different states?
0
and 1
?
That sounds a lot like How do you destruct and reconstruct your message on both sides?
Well, not so much in here. If you've tested it, and it works, you should be fine.#Cleaning Up
(+ No leaks, segfaults, only one global variable – the standard stuff.)
Weell – you now can send general signals to any process you know the ID of. So why only send And if you haven't got enough fun so far: You can get a pretty comprehensive list with or on your favourite manpage.#Aftercare
SIGUSR1
& SIGUSR2
?
Send the following to your server:
(well, shoot at might fit better, in those cases.)SIGSEGV
SIGBUS
SIGTERM
SIGKILL
$ kill -l
That was nice, wasn't it?
See you again soon.
And may your signals ever reach their destination.
#Pointers