| About | Custom Tester | Subject Compliance | Repository Layout | Build & Integration | Usage Guidelines | Conversion/Feature Tables | Flags & Feature Handling | Internal Architecture | Tester Workflow | Results & Reporting | Related Projects |
server.cboots withsigactionconfigured forSA_SIGINFO | SA_RESTART | SA_NODEFER, mappingSIGUSR1andSIGUSR2onto a bit accumulator soactionrebuilds characters inside a staticbit_buffer.process_characterlazily allocates aBUFFER_SIZE(100000) heap buffer, appends bytes until a null terminator arrives, prints throughft_printf, and frees/reset state before acknowledging the sender.client.cvalidates the supplied PID viakill(pid, 0), then streams each byte MSB-first throughsend_signal, blocking onpause()untilwait_validationtoggles thevolatileg_ack_receivedflag.- The bonus implementation keeps the same handshake while widening types to
unsigned char, so multi-byte UTF-8 payloads transit the signal channel without truncation.
make testercompiles both endpoints, cleans any staleresults/folder, and stages a fresh workspace for deterministic runs.start_serverlaunches./serverwrapped instdbuf -oL, wiring its stdout intoresults/server.outwhile persisting the background PID inresults/server.pidfor later teardown.- Test vectors live in
tester/test_cases.txtand the optionaltester/test_cases_bonus.txt; the Makefile prompts before concatenating the emoji-heavy bonus data intoresults/test_cases_combined.txt. - An
awk '{print NR, length($0), $0}'pipeline enumerates each message, echoing metadata to the terminal and piping the payloads into./client, which allows us to observe round-trip timing against varied lengths.
- The server prints its PID on launch through
ft_printf, then blocks onpause()with signals as the sole transport, fulfilling the mandatory requirements. SIGUSR1encodes zero bits andSIGUSR2encodes ones; the server acknowledges every bit viakill(info->si_pid, SIGUSR1)and issues a finalSIGUSR2after null termination, matching the bonus acknowledgment rules.- Heap usage stays bounded: the client works entirely on the stack, and the server owns exactly one
mallocd buffer per message that is freed immediately after printing. - Bonus sources reside in
_bonus.cfiles undersrcb/, andmake bonusswaps them in without touching the mandatory pipeline, keeping the evaluation paths isolated per subject guidelines.
src/contains the mandatoryclient.candserver.c, each exposing only static helpers so they remain Norm-compliant without extra headers.srcb/mirrors the mandatory structure withclient_bonus.candserver_bonus.c, replacing signed chars withunsigned charto guarantee emoji safety.tester/holdstest_cases.txtfor baseline coverage andtest_cases_bonus.txtpacked with extended UTF-8 data to exercise the bonus build.docs/ships the officialsubject_minitalk.pdfplusvideo/running_tester.webm(source capture) andvideo/running_tester.gif(embedded animation), giving reviewers instant tester context.Makefilewrites objects toobj/and runtime evidence toresults/, keeping the root clean between runs.
make(ormake all) lazily clones thelibftrepository if needed, builds it silently, and links both executables againstlibft.awith the mandated-Wall -Wextra -Werrorflags.make bonusreuses the same object rule, targets_bonussources, and relinks the binaries so you can toggle UTF-8 support without manual file juggling.make cleanremovesobj/, binaries, andresults/, whilemake fcleanadditionally nukes the vendoredlibftbeforemake rerestores the toolchain, matching the subject's relinking expectations.VFLAGSoffers a ready-made Valgrind configuration (--leak-check=full --show-leak-kinds=all --track-origins=yes), so deep diagnostics are a one-liner away when investigating signal timing.
- Build the project (
makeormake bonus), then launch./server; it printsServer PID: <pid>and waits indefinitely for clients. - From another terminal, call
./client <server_pid> "message"; each character is shifted out MSB-first, and the client blocks onpause()until the server acknowledges each bit throughwait_validation. - Completion is explicit: the client remains alive until the server emits a
SIGUSR2, whichterminate_clienttraps to exit only after the message is flushed. BUFFER_SIZEguards the per-message allocation; if a payload would overflow,process_charactersimply stops appending beyondBUFFER_SIZE - 1, avoiding undefined writes while still acknowledging progress.
- The table below contrasts mandatory and bonus traits, linking each behavior to the underlying helpers so reviewers can map features back to source instantly.
| Capability | Mandatory Build | Bonus Build |
|---|---|---|
| Character encoding | Signed char flow handled by process_character in server.c |
unsigned char pipeline in server_bonus.c keeps multi-byte UTF-8 data intact |
| Delivery guarantee | Bit-level ACK via kill(info->si_pid, SIGUSR1) inside action |
Same ACK plus final SIGUSR2 captured by terminate_client to close the session |
| Throughput handling | pause() loop with SA_RESTART avoids busy waits while processing bits |
Identical guard ensures Unicode bursts do not trigger signal loss |
| Buffer management | Lazy malloc reset per message ensures quick reuse of BUFFER_SIZE |
Same pattern, coupled with explicit error messaging on allocation failure |
- Because both builds share the
send_signalroutine, message ordering stays identical; the bonus path simply propagates every byte emitted by UTF-8 encoders.
- Both builds register handlers with
SA_SIGINFO, giving direct access toinfo->si_pidso the server can reply to any client without global state tracking. SA_NODEFERkeeps handlers reentrant, allowing consecutive signals to arrive without being blocked; theprocessingguard inactiondocuments that the decoder expects serialized delivery.- Handler functions set
SA_RESTART, ensuring syscalls likepause()resume automatically after signal handling, which keeps both processes responsive without manual loops. - The shared
g_ack_receivedflag is markedvolatileso the compiler respects updates performed inside signal handlers, preserving synchronization across the asynchronous boundary.
maininclient.cvalidates input count, converts the PID throughft_atoi, sanity-checks it usingkill(pid, 0), and then registerswait_validationandterminate_clientbefore dispatching tosend_message.send_messageiterates over every byte, callingsend_signalwhich shifts each bit out from position 7 down to 0, invokingkill(server_pid, SIGUSR1|SIGUSR2)and pausing until the server replies.actioninserver.cleft-shiftsbit_buffer, ORs in1when receivingSIGUSR2, incrementsbit_index, and once eight bits land, forwards the byte toprocess_characterbefore resetting its local state.- When
process_characterreceives\0, it prints the accumulated string, frees the heap buffer, resets indices, and signals completion viaSIGUSR2, making the server ready for the next client instantly.
- Invoking
make testerfirst ensures the previous server instance is stopped, then relaunches a fresh one and waits untilresults/server.outcontains the PID banner. - The Makefile copies
tester/test_cases.txtintoresults/test_cases_combined.txt, optionally appending the bonus suite when you answeryat the prompt. - The AWK loop emits
Test IDandLengthmetadata before calling./client, letting you see latency against message sizes in real time while the server logs the reconstructed text. - After all cases run,
tail -n +2 results/server.out | diff -u results/test_cases_combined.txt -compares expected versus received payloads, teeing discrepancies intoresults/diff.logfor post-run inspection.
- Success path prints
All Tests PASSED congratulations!from the tester, confirming the diff produced no mismatches and that the signal handshake matched the ground truth data. - Any divergence triggers a red
FAILEDbanner and leaves a unified diff inresults/diff.log, pinpointing the first mismatched line so you can replay the scenario quickly. - Real-time server output streams through the spawned
tail -f results/server.outterminal, making it easy to correlate client logs with server echoes during debugging sessions. - Cleaning via
make cleanremoves both the log and PID files, so each tester execution starts from a blank reporting slate.