void myHandler(void) { cout << "\t\t*******************" << endl; cout << "\t\tIn the exit handler" << endl; cout << "\t\t*******************" << endl; } ... atexit(myHandler);
#!/usr/bin/bash
for var in list of var; do code to execute. done
for type in --exit --exit_ --return --abort --fall; do echo echo "running myExit with " $type echo myExit $type echo "Exit Code: " $? echo echo read -p "Press enter to continue: " junk done
void Handler3(int code, void * data) { cout << endl; cout << "Handler 3 called status= " << code << " data= " << int(data) << endl; cout << endl; return; } ... on_exit(Handler3, 42);
CXXFLAGS = -g -O3 -Wall -Wextra -Wuninitialized -pedantic -Wshadow -Weffc++ -st d=c++14 # a special rule for exit2, playing lose and free with casts exit2: CXXFLAGS = -g -O3 -std=c++14 -w -fpermissive OBJS = mySleep myNanoSleep fork zombie orphan forkBomb myExit exit2 all: ${OBJS}