xref: /csrg-svn/usr.bin/f77/libU77/fork_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
42541Sdlw  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623013Skre  */
723013Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)fork_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223013Skre /*
132541Sdlw  * fork a copy of this process
142541Sdlw  *
152541Sdlw  * calling sequence:
162541Sdlw  *	integer fork
172541Sdlw  *	ierror = fork()
182541Sdlw  * where:
192541Sdlw  *	ierror will be	- child pid if parent and successful
202541Sdlw  *			- 0 if child
212541Sdlw  *			- -errno if unsuccessful
222541Sdlw  */
232541Sdlw 
242541Sdlw #include	"../libI77/fiodefs.h"
252541Sdlw 
262541Sdlw extern int errno;
272541Sdlw 
fork_()282541Sdlw long fork_()
292541Sdlw {
302541Sdlw 	long i;
312541Sdlw 
322541Sdlw 	for (i = 0; i < MXUNIT; i++)
332541Sdlw 		flush_(&i);
342541Sdlw 	i = (long)fork();
352541Sdlw 	if (i < 0)
362541Sdlw 		return((long)(-errno));
372541Sdlw 	return(i);
382541Sdlw }
39