diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-17 21:41:51 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-17 21:41:51 +0000 |
commit | 487ca4806cc046076293cf6cc5fbba0db282bac7 (patch) | |
tree | 847b412ab5158dd7bdd7ed7e5a4cc3fbca94be32 /Build/source/texk/web2c/lib/coredump.c | |
parent | a3d3111bfe26b8e5f5bc6049dfb2a4ca2edc7881 (diff) |
texk 1
git-svn-id: svn://tug.org/texlive/trunk@1485 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/lib/coredump.c')
-rw-r--r-- | Build/source/texk/web2c/lib/coredump.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/lib/coredump.c b/Build/source/texk/web2c/lib/coredump.c new file mode 100644 index 00000000000..b465969294c --- /dev/null +++ b/Build/source/texk/web2c/lib/coredump.c @@ -0,0 +1,58 @@ +/* coredump.c. Public domain. + + This procedure is due to Chris Torek, chris@umd.edu. It makes a core + dump without any sort of error status (abort(2) does return an error + status, so we don't want to use that). It is used only when making a + preloaded TeX from virtex, and is triggered by a magic file name + requested as input (see `open_input', above). Finding a way to + reconstitute the core dump into a binary (i.e., with undump) is up to + you. Perl has some things to say about these days. */ + +#include "config.h" + +/* Do not try to compile this Unix-y unportable stuff unless it's needed. */ + +#ifdef FUNNY_CORE_DUMP +#include <signal.h> +#include <sys/wait.h> + +void +funny_core_dump P1H(void) +{ +#ifdef __EMX__ + { + int handle = open ("core", O_WRONLY | O_CREAT | O_TRUNC | O_BINARY); + if (handle >= 0 && _core (handle) == 0) + exit (0); + (void) write (2, "attempt to dump core failed\n", 28); + exit (1); + } +#else /* !__EMX__ */ + int pid, w; + union wait status; + + switch (pid = fork ()) + { + case -1: /* failed */ + perror ("vfork"); + exit (-1); + /*NOTREACHED*/ + + case 0: /* child */ + (void) signal (SIGQUIT, SIG_DFL); + (void) kill (getpid (), SIGQUIT); + (void) write (2, "how did we get here?\n", 21); + _exit (1); + /*NOTREACHED*/ + + default: /* parent */ + while ((w = wait (&status)) != pid && w != -1) + ; + if (status.w_coredump) + exit (0); + (void) write (2, "attempt to dump core failed\n", 28); + exit (1); + } +#endif /* not __EMX__ */ +} +#endif /* FUNNY_CORE_DUMP */ |