Skip to content

Commit

Permalink
FIXME cleanup...don't use _exit() directly, but wrap it in the platfo…
Browse files Browse the repository at this point in the history
…rm layer.
  • Loading branch information
icculus committed Dec 9, 2006
1 parent 812a3e5 commit 3caa029
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
4 changes: 1 addition & 3 deletions misc.c
@@ -1,5 +1,3 @@
#include <unistd.h> // !!! FIXME: for _exit().

#include "universal.h"
#include "platform.h"
#include "gui.h"
Expand Down Expand Up @@ -53,7 +51,7 @@ int panic(const char *err)
fprintf(stderr, "\n\n\n%s\n %s\n\n\n", _("PANIC"), err);

else // panic is panicking in a loop, terminate without any cleanup...
_exit(22);
MojoPlatform_die();

exit(22);
return 0; // shouldn't hit this.
Expand Down
7 changes: 7 additions & 0 deletions platform.h
Expand Up @@ -17,6 +17,13 @@ const char *MojoPlatform_appBinaryPath(void);

uint32 MojoPlatform_ticks(void);

// Make current process kill itself immediately, without any sort of internal
// cleanup, like atexit() handlers or static destructors...the OS will have
// to sort out the freeing of any resources, and no more code in this
// process than necessary should run. This function does not return. Try to
// avoid calling this.
void MojoPlatform_die(void);

// Get the current locale, in the format "xx_YY" where "xx" is the language
// (en, fr, de...) and "_YY" is the country. (_US, _CA, etc). The country
// can be omitted. Don't include encoding, it's always UTF-8 at this time.
Expand Down
10 changes: 8 additions & 2 deletions platform/unix.c
Expand Up @@ -2,15 +2,15 @@
#include <Carbon/Carbon.h>
#endif

#include "../platform.h"

#include <time.h>
#include <sys/time.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>

#include "../platform.h"

static struct timeval startup_time;


Expand Down Expand Up @@ -185,5 +185,11 @@ uint32 MojoPlatform_ticks(void)
return ((uint32) (now_ms - then_ms));
} // MojoPlatform_ticks


void MojoPlatform_die(void)
{
_exit(86);
} // MojoPlatform_die

// end of unix.c ...

0 comments on commit 3caa029

Please sign in to comment.