1*41841Sbostic/*- 2*41841Sbostic * Copyright (c) 1990 The Regents of the University of California. 3*41841Sbostic * All rights reserved. 4*41841Sbostic * 5*41841Sbostic * This code is derived from software contributed to Berkeley by 6*41841Sbostic * the Systems Programming Group of the University of Utah Computer 7*41841Sbostic * Science Department. 8*41841Sbostic * 9*41841Sbostic * %sccs.include.redist.c% 10*41841Sbostic */ 11*41841Sbostic 12*41841Sbostic#if defined(LIBC_SCCS) && !defined(lint) 13*41841Sbostic .asciz "@(#)Ovfork.s 5.1 (Berkeley) 05/12/90" 14*41841Sbostic#endif /* LIBC_SCCS and not lint */ 15*41841Sbostic 16*41841Sbostic/* 17*41841Sbostic * @(#)vfork.s 4.1 (Berkeley) 12/21/80 18*41841Sbostic * C library -- vfork 19*41841Sbostic */ 20*41841Sbostic 21*41841Sbostic/* 22*41841Sbostic * pid = vfork(); 23*41841Sbostic * 24*41841Sbostic * d1 == 0 in parent process, d1 == 1 in child process. 25*41841Sbostic * d0 == pid of child in parent, d0 == pid of parent in child. 26*41841Sbostic * 27*41841Sbostic * trickery here, due to keith sklower, uses ret to clear the stack, 28*41841Sbostic * and then returns with a jump indirect, since only one person can return 29*41841Sbostic * with a ret off this stack... we do the ret before we vfork! 30*41841Sbostic */ 31*41841Sbostic 32*41841Sbostic vfork = 66 33*41841Sbostic.globl _vfork 34*41841Sbostic 35*41841Sbostic_vfork: 36*41841Sbostic movl sp@+,a0 37*41841Sbostic movl #vfork,d0 38*41841Sbostic trap #0 39*41841Sbostic jcc vforkok 40*41841Sbostic jmp verror 41*41841Sbosticvforkok: 42*41841Sbostic tstl d1 /* child process ? */ 43*41841Sbostic jne child /* yes */ 44*41841Sbostic jcc parent /* if c-bit not set, fork ok */ 45*41841Sbostic .globl _errno 46*41841Sbosticverror: 47*41841Sbostic movl d0,_errno 48*41841Sbostic moveq #-1,d0 49*41841Sbostic jmp a0@ 50*41841Sbosticchild: 51*41841Sbostic clrl d0 52*41841Sbosticparent: 53*41841Sbostic jmp a0@ 54