xref: /original-bsd/usr.bin/f77/libU77/fork_.c (revision 3a8172c6)
1 /*-
2  * Copyright (c) 1980 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.proprietary.c%
6  */
7 
8 #ifndef lint
9 static char sccsid[] = "@(#)fork_.c	5.2 (Berkeley) 04/12/91";
10 #endif /* not lint */
11 
12 /*
13  * fork a copy of this process
14  *
15  * calling sequence:
16  *	integer fork
17  *	ierror = fork()
18  * where:
19  *	ierror will be	- child pid if parent and successful
20  *			- 0 if child
21  *			- -errno if unsuccessful
22  */
23 
24 #include	"../libI77/fiodefs.h"
25 
26 extern int errno;
27 
28 long fork_()
29 {
30 	long i;
31 
32 	for (i = 0; i < MXUNIT; i++)
33 		flush_(&i);
34 	i = (long)fork();
35 	if (i < 0)
36 		return((long)(-errno));
37 	return(i);
38 }
39