I'm trying to do some cleanup (write open files) when Linux shuts down. I thought the right method would be to trap SIGTERM and do the necessary processing. Here's my sample code:
Code:
#include <stdio.h> // for File I/O
#include <signal.h> // for signals
#include <unistd.h> // for sleep()
void handler(int signal)
{
FILE *out=fopen("test.txt","at");