0

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 a command is given to turn off the key logger).

If I take out the line atexit(final) in my main, everything works properly. But I need atexit() function in my code to take care of what happens when the person exits the shell.

Thanks in advance.

thetypist
  • 333
  • 1
  • 4
  • 16
  • 1
    This code won't even compile. The main() function is incomplete, and there are several variable declarations missing. – John Saxton Nov 29 '13 at 02:39
  • Sorry I removed variable declarations and irrelevant code. My actual main has a return O and everything :) – thetypist Nov 29 '13 at 02:41
  • If this accurately reflects your real code you are registering the `atexit` (and `signal`) every time through the input loop. If that's the case final is going to be called multiple times and probably won't react well to trying to read deleted files. – Duck Nov 29 '13 at 03:04
  • How can I fix this, Duck? – thetypist Nov 29 '13 at 03:26
  • Please provide a test program which is as small as possible and which demonstrates your problem. – Michael Nov 29 '13 at 06:09

0 Answers0