141841Sbostic/*- 2*62568Sbostic * Copyright (c) 1990, 1993 3*62568Sbostic * The Regents of the University of California. All rights reserved. 441841Sbostic * 541841Sbostic * This code is derived from software contributed to Berkeley by 641841Sbostic * the Systems Programming Group of the University of Utah Computer 741841Sbostic * Science Department. 841841Sbostic * 941841Sbostic * %sccs.include.redist.c% 1041841Sbostic */ 1141841Sbostic 1241841Sbostic#if defined(LIBC_SCCS) && !defined(lint) 13*62568Sbostic .asciz "@(#)Ovfork.s 8.1 (Berkeley) 06/07/93" 1441841Sbostic#endif /* LIBC_SCCS and not lint */ 1541841Sbostic 1641841Sbostic/* 1741841Sbostic * pid = vfork(); 1841841Sbostic * 1941841Sbostic * d1 == 0 in parent process, d1 == 1 in child process. 2041841Sbostic * d0 == pid of child in parent, d0 == pid of parent in child. 2141841Sbostic * 2241841Sbostic * trickery here, due to keith sklower, uses ret to clear the stack, 2341841Sbostic * and then returns with a jump indirect, since only one person can return 2441841Sbostic * with a ret off this stack... we do the ret before we vfork! 2541841Sbostic */ 2641841Sbostic 2762567Sbostic#include "SYS.h" 2862567Sbostic 2941841Sbostic vfork = 66 3062565SbosticENTRY(vfork) 3141841Sbostic movl sp@+,a0 3241841Sbostic movl #vfork,d0 3341841Sbostic trap #0 3441841Sbostic jcc vforkok 3541841Sbostic jmp verror 3641841Sbosticvforkok: 3741841Sbostic tstl d1 /* child process ? */ 3841841Sbostic jne child /* yes */ 3941841Sbostic jcc parent /* if c-bit not set, fork ok */ 4041841Sbostic .globl _errno 4141841Sbosticverror: 4241841Sbostic movl d0,_errno 4341841Sbostic moveq #-1,d0 4441841Sbostic jmp a0@ 4541841Sbosticchild: 4641841Sbostic clrl d0 4741841Sbosticparent: 4841841Sbostic jmp a0@ 49