Skip to content
Snippets Groups Projects
Commit f5bf2ec4 authored by deuce's avatar deuce
Browse files

Finally track down the "two instances of SyncTERM running, one using 100% CPU"

problem and kill it once and for all by doing terrible terrible things.

Essentially, the problem stems from SDL installing an atexit() handler and
cryptlib calling exit() after a fork().  This causes the child to attempt
to shut down SDL (which isn't running in the child) which apparently spins.

I've "fixed" this by overriding exit()!!!  So any exit() call will not call
atexit() functions from SyncTERM anymore.

I haven't yet decided if this is a cryptlib bug or an SDL bug, though I'm
leaning toward SDL.
parent 3bad8ecf
Branches
Tags
No related merge requests found
/* Copyright (C), 2007 by Stephen Hurd */
#include <stdio.h> /* NULL */
#include <unistd.h> /* _exit() */
#include "st_crypt.h"
#include <xp_dl.h>
......@@ -19,6 +20,22 @@ void exit_crypt()
#else
/*
* cryptlib calls fork() to gather entropy.
* It then calls exit().
* This calls the atexit() handlers.
* SDL_Exit is in there...
* SDL doesn't exist in the forked child.
* This causes the child to spin FOREVER
* Eating your CPU.
* So, we will break exit(3).
*/
void exit(int code)
{
fclose(fopen("/tmp/Dumbass", "w"));
_exit(code);
}
struct crypt_funcs cl;
int init_crypt(void)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment