2014-01-01 11:03:15 +00:00
|
|
|
/* Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
1999-01-21 09:26:20 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
Contributed by Andreas Schwab <schwab@gnu.org>.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
2001-07-06 04:58:11 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
1999-01-21 09:26:20 +00:00
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2001-07-06 04:58:11 +00:00
|
|
|
Lesser General Public License for more details.
|
1999-01-21 09:26:20 +00:00
|
|
|
|
2001-07-06 04:58:11 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-02-09 23:18:22 +00:00
|
|
|
License along with the GNU C Library; if not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
1999-01-21 09:26:20 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#define _ERRNO_H 1
|
|
|
|
#include <bits/errno.h>
|
2002-10-16 04:39:59 +00:00
|
|
|
#include <kernel-features.h>
|
1999-01-21 09:26:20 +00:00
|
|
|
|
|
|
|
/* Clone the calling process, but without copying the whole address space.
|
|
|
|
The calling process is suspended until the new process exits or is
|
|
|
|
replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
|
|
|
|
and the process ID of the new process to the old process. */
|
|
|
|
|
|
|
|
ENTRY (__vfork)
|
|
|
|
|
|
|
|
/* Pop the return PC value into ECX. */
|
|
|
|
popl %ecx
|
2005-05-04 17:58:13 +00:00
|
|
|
cfi_adjust_cfa_offset (-4)
|
2008-04-09 18:30:12 +00:00
|
|
|
cfi_register (%eip, %ecx)
|
1999-01-21 09:26:20 +00:00
|
|
|
|
2004-03-09 06:32:58 +00:00
|
|
|
#ifdef SAVE_PID
|
|
|
|
SAVE_PID
|
|
|
|
#endif
|
|
|
|
|
1999-01-21 09:26:20 +00:00
|
|
|
/* Stuff the syscall number in EAX and enter into the kernel. */
|
|
|
|
movl $SYS_ify (vfork), %eax
|
|
|
|
int $0x80
|
2002-10-16 04:39:59 +00:00
|
|
|
|
|
|
|
/* Jump to the return PC. Don't jump directly since this
|
|
|
|
disturbs the branch target cache. Instead push the return
|
|
|
|
address back on the stack. */
|
|
|
|
pushl %ecx
|
2005-05-04 17:58:13 +00:00
|
|
|
cfi_adjust_cfa_offset (4)
|
2002-10-16 04:39:59 +00:00
|
|
|
|
2004-03-09 06:32:58 +00:00
|
|
|
#ifdef RESTORE_PID
|
|
|
|
RESTORE_PID
|
|
|
|
#endif
|
|
|
|
|
1999-01-21 09:26:20 +00:00
|
|
|
cmpl $-4095, %eax
|
2002-10-16 04:39:59 +00:00
|
|
|
/* Branch forward if it failed. */
|
|
|
|
jae SYSCALL_ERROR_LABEL
|
1999-01-21 09:26:20 +00:00
|
|
|
|
2002-10-16 04:39:59 +00:00
|
|
|
ret
|
1999-01-21 09:26:20 +00:00
|
|
|
|
|
|
|
PSEUDO_END (__vfork)
|
2002-12-31 20:46:11 +00:00
|
|
|
libc_hidden_def (__vfork)
|
1999-01-21 09:26:20 +00:00
|
|
|
|
|
|
|
weak_alias (__vfork, vfork)
|