1 /* coredump.c. Public domain.
3 This procedure is due to Chris Torek, chris@umd.edu. It makes a core
4 dump without any sort of error status (abort(2) does return an error
5 status, so we don't want to use that). It is used only when making a
6 preloaded TeX from virtex, and is triggered by a magic file name
7 requested as input (see `open_input', above). Finding a way to
8 reconstitute the core dump into a binary (i.e., with undump) is up to
9 you. Perl has some things to say about these days. */
11 #include <w2c/config.h>
13 /* Do not try to compile this Unix-y unportable stuff unless it's needed. */
15 #ifdef FUNNY_CORE_DUMP
20 funny_core_dump (void)
24 int handle
= open ("core", O_WRONLY
| O_CREAT
| O_TRUNC
| O_BINARY
);
25 if (handle
>= 0 && _core (handle
) == 0)
27 (void) write (2, "attempt to dump core failed\n", 28);
34 switch (pid
= fork ())
42 (void) signal (SIGQUIT
, SIG_DFL
);
43 (void) kill (getpid (), SIGQUIT
);
44 (void) write (2, "how did we get here?\n", 21);
49 while ((w
= wait (&status
)) != pid
&& w
!= -1)
51 if (status
.w_coredump
)
53 (void) write (2, "attempt to dump core failed\n", 28);
56 #endif /* not __EMX__ */
58 #endif /* FUNNY_CORE_DUMP */