Questions tagged [atexit]

atexit(3) is a method for arranging a function to be called at a program's exit time.

162 questions
0
votes
3 answers

MinGW GCC - undefined reference to `atexit'

I am trying to link a large project with GCC 4.8.1 from MinGW for a x86 target. I am calling the linker like this D:\MyGCCPath\gcc -L [LIBPATHS] -nostdlib -Wl,-Map,D:\PathToMapFile.map,--emit-relocs [OBJECTFILES AND LIBS] -lmsvcrt -lgcc -o…
Toby
  • 3,815
  • 14
  • 51
  • 67
0
votes
1 answer

Main Loop doesn't exit Normally

I have created this function which acts as the Main Menu for a Terminal-based application: bool wizard_run() { char *command = NULL; bool repeat = false; bookmark: terminal_prepare(); terminal_message(MESSAGE_INTRODUCTION); loop:…
someone
  • 361
  • 2
  • 3
  • 13
0
votes
3 answers

Why isn't atexit registering in python?

I have a loop in Tkinter: def main(): #Global Variables windows = [] buttons = [] labels = [] messageboxes = [] global theme theme = 0 listboxes = [] global register register = [] global path path =…
madprogramer
  • 599
  • 3
  • 12
  • 36
0
votes
1 answer

How can I call a routine automatically when the run ends in specman?

Is there any way to specify that a function should be called when a test ends in Specman? I'm looking for something similar to C's atexit().
Nathan Fellman
  • 122,701
  • 101
  • 260
  • 319
-1
votes
1 answer

C++ Problem with atexit(); "void" incompatible with "void (__cdecl *)()"

I want to delete all .txt files in the folder where the executable is located when the program closes. To delete the files I use system("del /s *.txt");, but I want to do it when the program closes so I've made a void function void deleteTxt() { …
-1
votes
1 answer

Trap exit on console

I would like to call a cleanup function after the user presses the small "x" at the top right hand corner of the console window. I have registered an atexit method but this doesn't get called in this case. Solution needs to work on windows and…
Jacko
  • 12,665
  • 18
  • 75
  • 126
-1
votes
6 answers

Another way to do cleanup in C?

Consider this program: int main(void) { int* i = malloc(sizeof(int)); int* j = malloc(sizeof(int)); } However this is a naive approach, because malloc may fail and the pointers are not free'd. So you can do this: int main(void) { int*…
hgiesel
  • 5,430
  • 2
  • 29
  • 56
-1
votes
1 answer

Why would you call the same Exit Handlers (atexit function) more than once?

The function: int atexit (void (*function) (void)) allows us to call the same exit handling functions more than once. Why would you call the exit handlers more than once? Could you give me an example where it makes sense to call the same exit…
-1
votes
1 answer

Why don't I get an infinite loop when I call exit from an atexit handler?

This program register a function calling exit() with atexit(). #include #include void machiavellian() { puts("At exit"); exit(0); } int main(void) { atexit(machiavellian); exit(0); } From man atexit These…
toasted_flakes
  • 2,502
  • 1
  • 23
  • 38
-2
votes
1 answer

change the exit status of a C/C++ program during atexit callback

I'm looking for a way to change the exit status of a C/C++ program during an atexit callback sequence. I'm develping some C++ code that registers a book keeping function with atexit. If the program terminates as a result of an exit() call, this book…
user3195869
  • 75
  • 1
  • 6
-2
votes
2 answers

How to pass in different function pointers into atexit in c?

I understand that atexit() takes in a function pointer of this type void (*function)(void). What I want to do is that whenever the porgam exists it runs a function to free of all the memory. So I want atexit() to take in this function pointer…
carlosdafield
  • 1,479
  • 5
  • 16
-4
votes
1 answer

C++ Send e-mail at exit

What I'm trying to do is send an e-mail when exiting my program. I use atexit(); function to do this but... it's not working properly. #include #include void SendEmail() { //lot of code here } void Print() { …
user5446899
1 2 3
10
11