Build Errors
Missing Dependencies
Missing Dependencies
Minitalk requires the custom
libft library with ft_printf implementation.Solution:- Ensure
libft/ft_printf.hexists and is accessible - The header must include declarations for:
int ft_printf(char const *str, ...)- Standard library includes:
<stdio.h>,<unistd.h>,<stdarg.h>,<stdlib.h>
- Build the libft library before compiling minitalk
Compilation Flag Issues
Compilation Flag Issues
The project requires proper signal handling support.Solution:
- Ensure your compiler supports POSIX signal handling
- Required headers must be available:
<signal.h>,<unistd.h> - Compile on a UNIX-like system (Linux, macOS, BSD)
Linking Errors
Linking Errors
Errors about undefined references to
ft_printf or related functions.Solution:- Link against the compiled libft library
- Ensure all
ft_printfhelper functions are included:ft_write_strft_write_numft_write_pointerft_write_char
Runtime Errors
Wrong PID Error
Wrong PID Error
Error Message:Cause:
The client validates that the PID argument contains only numeric characters. This error occurs when:Solution:
- The PID contains non-digit characters
- The PID includes letters, symbols, or spaces
client.c:77-84- Ensure the PID is numeric only (e.g.,
12345, not12a45) - Get the correct server PID from the server’s startup output
- Do not include spaces or special characters in the PID
Client Failed Sending Signal
Client Failed Sending Signal
Error Message:Cause:
The Solution:
kill() system call returned -1, indicating signal delivery failed. This happens when:- The target PID does not exist
- The target process has terminated
- Permission denied (trying to signal a process owned by another user)
- Invalid PID value (0, negative, or exceeds system maximum)
client.c:55-61- Verify the server is running:
ps -p <PID> - Check that the PID matches the server’s displayed PID exactly
- Ensure you have permission to send signals to the process
- Run both client and server as the same user
- If the server crashed, restart it and use the new PID
Usage Error
Usage Error
Error Message:Cause:
The client requires exactly 3 arguments (program name, PID, message). This error occurs when:Solution:
- Wrong number of arguments provided
- Empty string provided as the message (NULL check fails)
client.c:75-76Signal Delivery Issues
Message Not Received or Corrupted
Message Not Received or Corrupted
Symptoms:
- Server displays garbled characters
- Only partial message appears
- Random characters printed
-
Signal handler not properly registered
- Server must call
signal(SIGUSR1, handle_sigusr)andsignal(SIGUSR2, handle_sigusr)before entering main loop - Verify in
server.c:38-39
- Server must call
-
Server not running in pause loop
- Server must call
pause()to wait for signals - Verify infinite loop at
server.c:40-43
- Server must call
-
Race condition between signals
- Signals sent too quickly may not all be processed
- See timing issues below
- Ensure server displays startup messages including PID
- Verify signal handlers are registered before client sends signals
- Check that server process remains running during transmission
Permission Denied
Permission Denied
Symptoms:
- Client fails immediately with “Client failed sending signal”
kill()returns -1 with EPERM error
- Run both server and client as the same user
- Check process ownership:
ps -o user,pid,comm -p <PID> - Do not run server as root unless necessary
- If using sudo, run both processes with sudo (not recommended)
Server Not Responding
Server Not Responding
Symptoms:Solution:
- Client completes without errors
- Server displays nothing or incomplete message
- No output after server startup
- Server blocked or hung
- Signal handlers not properly set up
- Server terminated unexpectedly
- Restart the server
- Check server output for error messages
- Ensure server’s
pause()loop is executing - Verify signal handlers are correctly registered
Timing Problems
usleep Value Too Low
usleep Value Too Low
Current Value:
usleep(700) - 700 microseconds between signalsLocation: client.c:63Symptoms if too low:- Signals arrive before previous signal is fully processed
- Operating system may merge or drop signals
- Characters appear corrupted or missing
- Message only partially received
- UNIX signals are not queued by default for SIGUSR1/SIGUSR2
- If multiple identical signals arrive while one is being handled, extras may be lost
- Signal handler execution takes time
- System scheduling introduces delays
- If experiencing corruption, increase to
usleep(1000)or higher - Test with longer delays first, then optimize downward
- Balance between speed and reliability
System Load Impact
System Load Impact
Symptoms:
- Messages work sometimes but fail under load
- Corruption occurs when system is busy
- Reliable on quiet system, unreliable otherwise
- Increase
usleep()delay to 1000-2000 microseconds - Reduce system load (close unnecessary processes)
- Consider implementing acknowledgment mechanism (bonus feature)
Testing Different Delays
Testing Different Delays
To test different timing values, modify the usleep call in Testing procedure:
client.c:63:- Start server:
./server - Send test messages of varying lengths
- Verify complete, uncorrupted output
- Test with different system loads
- Find minimum reliable delay for your system
Server-Specific Issues
Server Doesn't Display PID
Server Doesn't Display PID
Expected Output:If nothing appears:
- Check that server executable has correct permissions
- Ensure
ft_printfis linked correctly - Verify server compiles without errors
- Run with output redirection:
./server > output.txt 2>&1
- Rebuild the project completely
- Test
ft_printfindependently - Check that stdout is not redirected or buffered
Static Variables Not Resetting
Static Variables Not Resetting
Issue:
The Behavior:
handle_sigusr function uses static variables c and i to maintain state between signal handler calls.Location: server.c:18-19- Variables persist across all signal handler invocations
- Not reset between different messages
- Reset only after completing each character (every 8 bits)
- First message works correctly
- Subsequent messages continue from previous state
- If client connection interrupted mid-character, server state may be misaligned
- Restart server between messages if corruption occurs
- This is expected behavior for the basic implementation
- Advanced solution: implement message delimiters or reset signals