core files under SV

Chris Torek chris at mimsy.umd.edu
Wed Nov 15 21:22:49 AEST 1989


In article <MRD.89Nov15011304 at image.clarkson.edu> mrd at sun.soe.clarkson.edu
(Michael DeCorte) writes:
>NOTE I want to generate a core file but NOT exit.  Yup I just want to
>go along on my merry way.

(You are not going to like this :-) )

int
make_core_file() {
	int pid = fork(), w, status;
	extern int errno;

	switch (pid) {

	case -1:
/*DEBUG*/	/* perror("cannot fork to make core file"); */
		return (-1);

	case 0: /* child */
		abort();
/*DEBUG*/	/* (void) write(2, "could not make core file\n", 25); */
		_exit(1);
		/* NOTREACHED */
	}
	/* parent */
	/* should use wait4() here, but no one has it yet */
	while ((w = wait(&status)) != pid)
		if (w == -1 && errno != EINTR)
			break;
	if (status & 0200)	/* made a core file */
		return (0);
	return (1);		/* fork succeeded, but no core dump */
}
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at cs.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list