147918Sbostic /*- 2*61226Sbostic * Copyright (c) 1983, 1993 3*61226Sbostic * The Regents of the University of California. All rights reserved. 447911Sbostic * 547918Sbostic * %sccs.include.redist.c% 647911Sbostic */ 747911Sbostic 847911Sbostic #if defined(LIBC_SCCS) && !defined(lint) 9*61226Sbostic .asciz "@(#)Ovfork.c 8.1 (Berkeley) 06/04/93" 1047911Sbostic #endif /* LIBC_SCCS and not lint */ 1147911Sbostic 1247911Sbostic /* 1347911Sbostic * @(#)vfork.s 4.1 (Berkeley) 12/21/80 1447911Sbostic * C library -- vfork 1547911Sbostic */ 1647911Sbostic 1747911Sbostic /* 1847911Sbostic * pid = vfork(); 1947911Sbostic * 2047911Sbostic * r1 == 0 in parent process, r1 == 1 in child process. 2147911Sbostic * r0 == pid of child in parent, r0 == pid of parent in child. 2247911Sbostic * 2347911Sbostic * trickery here, due to keith sklower, uses ret to clear the stack, 2447911Sbostic * and then returns with a jump indirect, since only one person can return 2547911Sbostic * with a ret off this stack... we do the ret before we vfork! 2647911Sbostic */ 2747911Sbostic 2847911Sbostic .set vfork,66 2947911Sbostic .globl _vfork 3047911Sbostic .globl mypid, myppid 3147911Sbostic 3247911Sbostic _vfork: 3347911Sbostic .word 0x0000 3447911Sbostic movl 16(fp),r2 3547911Sbostic movab here,16(fp) 3647911Sbostic ret 3747911Sbostic here: 3847911Sbostic chmk $vfork 3947911Sbostic bcc vforkok 4047911Sbostic jmp verror 4147911Sbostic vforkok: 4247911Sbostic tstl r1 # child process ? 4347911Sbostic bneq child # yes 4447911Sbostic bcc parent # if c-bit not set, fork ok 4547911Sbostic .globl _errno 4647911Sbostic verror: 4747911Sbostic movl r0,_errno 4847911Sbostic mnegl $1,r0 4947911Sbostic jmp (r2) 5047911Sbostic child: 5147911Sbostic movl r0,myppid 5247911Sbostic clrl r0 5347911Sbostic clrl mypid 5447911Sbostic parent: 5547911Sbostic jmp (r2) 56