Skip to content

The purpose of this project is to code a small data exchange programusing UNIX signals.

Notifications You must be signed in to change notification settings

achrafelkhnissi/minitalk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

				███╗   ███╗██╗███╗   ██╗██╗████████╗ █████╗ ██╗     ██╗██╗			
				██╔████╔██║██║██╔██╗ ██║██║   ██║   ███████║██║     █████╔╝			 
				██║╚██╔╝██║██║██║╚██╗██║██║   ██║   ██╔══██║██║     ██╔═██╗			 
				██║ ╚═╝ ██║██║██║ ╚████║██║   ██║   ██║  ██║███████╗██║  ██╗			
				╚═╝     ╚═╝╚═╝╚═╝  ╚═══╝╚═╝   ╚═╝   ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝			

					PID: 0000			By: ael-khni
				⊱ ────────────────────── {.⋅ ✯ ⋅.} ─────────────────────── ⊰	

42cursus' minitalk

Development repo for 42cursus' ft_printf project
For further information about 42cursus and its projects, please refer to 42cursus repo.


Table of content

The purpose of this project is to code a small data exchange program using Unix signals.

Create a communication program - in C - in the form of a client and server. The server is the first one to be launched, having to display its PID after. The client will take as parameters the server PID and the string to be sent. Once the string has been received by the server, this one should display it.

This communication should only be done using Unix signals. Only two signals can be used SIGUSR1 and SIGUSR2. The executable files are named client and server.

  1. Unix Processes
  2. Unix Signals
  3. Used Function & their brief explaination!
  4. minitalk explained!

Project Information

About

The purpose of this project is to code a small data exchange program using UNIX signals.
Keep in mind:

  • You have to handle errors sensitively. In no way can your program quit unexpectedly (Segmentation fault, bus error, double free, etc).
  • Your program cannot have memory leaks.
  • You can use one global variable but it must be justified.

Mandatory

  • Produce server & client executables
  • client must communicate a string passed as a parameter to server (referenced by its process ID) which then displays it
  • Use SIGUSR1 & SIGUSR2 signals ONLY

Bonus

  • Add reception acknowledgement system
  • Support Unicode characters

Allowed Functions (manual)

Intro to signals

Signals are standardized messages sent to a running program to trigger specific behavior, such as quitting or error handling. They are a limited form of inter-process communication (IPC), typically used in POSIX-compliant operating systems.
When a signal is sent. the operating system interrupts the target process normal flow of executing to deliver the signal. Execution can be interrupted during any non-atomic instruction. If the process has previously registered a signal handler, that routine is executed. Otherwise, the default signal handler is executed.
A signal is an event generated by the UNIX and Linux systems in response to some condition. Upon receipt of a signal, a process may take action.
A signal is just like an interrupt; when it is generated at the user level, a call is made to the kernel of the OS, which then acts accordingly.
There are two types of signals:

  • Maskable: signals which can be changed or ignored by the user (e.g., Ctrl+C)
  • None-Maskable: Signals which cannot be changed or ignored by the user. These typically occurs when the user is signaled for non-recoverable hardware errors.

Handling signals

Signal handlers can be installed with the signal(2) or sigaction(2) system calls. If a signal handler is not installer for a particular signal, the fefault handler is user. Otherwise the signal is intercepted and the signal handler is invoked.
The signals are defined in the header file signal.h as a macro constant. Signal name has started with a “SIG” and followed by a short description of the signal. So, every signal has a unique numeric value. Your program should always use the name of the signals, not the signals number. The reason is signal number can differ according to system but meaning of names will be standard.
The macro NSIG is the total number of signal defined. The value of NSIG is one greater than the total number of signal defined (All signal numbers are allocated consecutively).

The following is a list of all signals with names as in the include file <signal.h>:

    No    Name         Default Action       Description
     1     SIGHUP       terminate process    terminal line hangup
     2     SIGINT       terminate process    interrupt program
     3     SIGQUIT      create core image    quit program
     4     SIGILL       create core image    illegal instruction
     5     SIGTRAP      create core image    trace trap
     6     SIGABRT      create core image    abort program (formerly SIGIOT)
     7     SIGEMT       create core image    emulate instruction executed
     8     SIGFPE       create core image    floating-point exception
     9     SIGKILL      terminate process    kill program
     10    SIGBUS       create core image    bus error
     11    SIGSEGV      create core image    segmentation violation
     12    SIGSYS       create core image    non-existent system call invoked
     13    SIGPIPE      terminate process    write on a pipe with no reader
     14    SIGALRM      terminate process    real-time timer expired
     15    SIGTERM      terminate process    software termination signal
     16    SIGURG       discard signal       urgent condition present on socket
     17    SIGSTOP      stop process         stop (cannot be caught or ignored)
     18    SIGTSTP      stop process         stop signal generated from keyboard
     19    SIGCONT      discard signal       continue after stop
     20    SIGCHLD      discard signal       child status has changed
     21    SIGTTIN      stop process         background read attempted from control terminal
     22    SIGTTOU      stop process         background write attempted to control terminal
     23    SIGIO        discard signal       I/O is possible on a descriptor (see fcntl(2))
     24    SIGXCPU      terminate process    cpu time limit exceeded (see setrlimit(2))
     25    SIGXFSZ      terminate process    file size limit exceeded (see setrlimit(2))
     26    SIGVTALRM    terminate process    virtual time alarm (see setitimer(2))
     27    SIGPROF      terminate process    profiling timer alarm (see setitimer(2))
     28    SIGWINCH     discard signal       Window size change
     29    SIGINFO      discard signal       status request from keyboard
     30    SIGUSR1      terminate process    User defined signal 1
     31    SIGUSR2      terminate process    User defined signal 2

Resources

Author

  • @achrafelkhnissi | Software Engineer Student

    Reach out to me if you need any help or have any questions.

    Feel free to contact me * Linkedin Profile * Twitter Profile * Discord Profile

About

The purpose of this project is to code a small data exchange programusing UNIX signals.

Topics

Resources

Stars

Watchers

Forks