Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Calling exit() from a signal handler is unsafe #457

Closed
bnoordhuis opened this issue Nov 26, 2010 · 3 comments
Closed

Calling exit() from a signal handler is unsafe #457

bnoordhuis opened this issue Nov 26, 2010 · 3 comments

Comments

@bnoordhuis
Copy link
Member

Alternatives:

  1. Call _exit(). Disadvantage: doesn't run atexit() cleanup handlers.
  2. Write-to-pipe trick. Disadvantage: signals may get lost if the pipe is full.
  3. Use a libev signal watcher. Disadvantage: lots of work to rewrite existing code?

By the way, libev uses the pipe trick on platforms other than linux so it too might miss signals.

@ry
Copy link

ry commented Nov 30, 2010

fixed in 711196c

coolaj86 pushed a commit that referenced this issue Apr 15, 2011
@Fishrock123
Copy link

@bnoordhuis could you clarify "unsafe"? I'm left wondering why this doesn't happen years later haha.

@bnoordhuis
Copy link
Member Author

@Fishrock123 exit() (unlike _exit()) runs atexit handlers and flushes stdio, leading to all kinds of memory corruption and deadlocks when the signal arrives at the wrong time.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants