This project demonstrates inter-process communication (IPC) in Linux using real-time signals to simulate terminate and abort functionality. It consists of two files:
- Receiver (rcv.c): Listens for real-time signals and performs specific actions based on the received signal's data.
- Sender (snd.c): Sends real-time signals with associated data to the receiver process.
- Uses real-time signals (
SIGRTMIN) for reliable communication. - Signal Data Handling:
- 0: Receiver terminates gracefully.
- 1: Receiver aborts with a core dump.
- The use of Signals:
sigactionfor setting up advanced signal handlers.sigqueuefor sending signals with additional data.
- Registers a signal handler for
SIGRTMINusingsigaction. - Processes signal data received via the
si_value.sival_intfield ofsiginfo_t. - Performs the following:
- Data
0: Logs a termination message and exits. - Data
1: Logs an abort message and triggers a core dump. - Logs a message for any other data.
- Data
- Accepts the following command-line arguments:
- PID: Process ID of the receiver.
- Data: Integer value (
0or1).
- Uses
sigqueueto sendSIGRTMINwith the specified data to the receiver.
gcc -o r rcv.c
gcc -o s snd.cStart the receiver application to listen for real-time signals:
./r- The receiver will print its PID (Process ID) upon launch.
Use the sender application to send a signal to the receiver:
./s <pid> <0 or 1><pid>: Process ID of the running receiver (printed by the receiver).<0 or 1>: Integer data to send:- 0: Terminates the receiver.
- 1: Aborts the receiver with a core dump.
- Real-Time Signals: Uses
SIGRTMINfor queuing and passing additional data. sigaction: Allows access to extended signal data using theSA_SIGINFOflag.sigqueue: Sends signals with payload data encapsulated in aunion sigval.
