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
1 answer

Python3 Running atexit only on the main process

I have a program that spawns multiple child processes, how would I make the program only call atexit.register(function) on the main process and not on the child processes as well? Thanks
0
votes
2 answers

Alternative to python atexit module that works when called from other scripts

Using atexit.register(function) to register a function to be called when your python script exits is a common practice. The problem is that I identified a case when this fails in an ugly way: if your script it executed from another python script…
sorin
  • 161,544
  • 178
  • 535
  • 806
0
votes
0 answers

How use atexit() function for free up memory?

This is simple code: #include #include void cleanUp(){ printf("I have to do free up memory\n"); } int main(){ char *temp; temp = (char *)malloc(10*sizeof(char)); atexit(cleanUp); exit(0); …
o_O
  • 51
  • 7
0
votes
1 answer

atexit for singleton destruction : failure case

From : https://sourcemaking.com/design_patterns/to_kill_a_singleton One thing's for sure: you can't use more than one destroyer if the singleton destructors depend on one another. An alternative is to eschew destroyers altogether and rely…
q126y
  • 1,589
  • 4
  • 18
  • 50
0
votes
1 answer

Can atexit() be called during a taskkill command?

I am trying to use the atexit function to call a function but it doesn't seem to work if I use a batch file to do a taskkill command on the program. Is there some way to make this work?
0
votes
1 answer

Using python, how do I launch an independent python process

I am making a python program, lets say A. Which is used to monitor python script B When the python program shuts down, there is an exit function that as registered via atexit.register(), to do some clean up it need to re-run python script B, which…
needoriginalname
  • 703
  • 3
  • 9
  • 27
0
votes
1 answer

atexit not writing to file

I'm testing to see if the atexit module runs properly by attempting to print to file. The actual purpose of atexit will be to close the open port, however this is to test if atexit is working in the first place. However, atexit is not printing to…
Gigsa
  • 1
0
votes
1 answer

Selenium chromedriver not playing nice with at_exit

Is this a bug in my code, or a bug in Selenium, RSpec, etc.? The Cucumber tests I'm writing need to shut down and re-launch the Chrome driver. However, I can't get this second driver to shut down properly. The stripped-down example below shows the…
Zack
  • 6,232
  • 8
  • 38
  • 68
0
votes
3 answers

Difference between .dtors and atexit() in C++

What is the difference between functions in .dtors and functions called using atexit()? As I understand, functions marked with the ((destructor)) attribute are located in the .dtors segment, and called after exit. Likewise, functions added using…
Rafa
  • 1,151
  • 9
  • 17
0
votes
1 answer

Execute code at exit

In my code I have function like this: def myfunc(): # Don't do anything if there's an instance already if get_var('running') == 'true': return set_var('running', 'true') # In case things go wrong …
ivknv
  • 305
  • 1
  • 4
  • 14
0
votes
0 answers

Python flushing log buffer at exit

I wrote a python script which executes a while loop and requires a keyboard interrupt or system shutdown to terminate. I would like my log file to save the log output; currently the log file gets created, but nothing gets written to it. The…
0
votes
2 answers

Why are threads interrupted even when atexit or ConsoleHandler for SetConsoleCtrlhandler is executed?

I have a multithreaded application under Windows 7. I need to correctly finish jobs in threads which have an open descriptors, connections and so on when a user presses 'X' in the corner of command line, 'Ctrl+C', shuts down OS and so on. I've set a…
flashnik
  • 1,900
  • 4
  • 19
  • 38
0
votes
1 answer

Where should atexit() function go in order to prevent seg fault?

My code works perfectly fine, however when I exit my simpleshell I get a segmentation fault. The final of atexit(final) still gets called and works properly. I think the problem is with the atexit(), because when atexit() is removed from the code I…
thetypist
  • 333
  • 1
  • 4
  • 16
0
votes
0 answers

Getting error when turning key logger off due to atexit() function

I get a segmentation fault (core dumped) when turning off my key logger when there is an atexit() function in my code. This is confusing because the atexit() function should only be called when somebody attempts to exit the program (not simply when…
thetypist
  • 333
  • 1
  • 4
  • 16
0
votes
1 answer

undefined reference to `atexit - bluez compilation

I am encountering this issue, when i try to cross-compile bluez-4.101, to mipsel-linux target. plugins/bluetoothd-hciops.o: In function `init_device': hciops.c:(.text+0xadc0): undefined reference to `atexit' hciops.c:(.text+0xadc8): undefined…
1 2 3
10
11