On Thu, Nov 15, 2012 at 10:16 PM, Rich Felker <dal...@aerifal.cx> wrote:
> On Tue, Nov 13, 2012 at 11:31:30AM +0000, Markos Chandras wrote:
>> From: Markos Chandras <markos.chand...@imgtec.com>
>>
>> Signed-off-by: Markos Chandras <markos.chand...@imgtec.com>
>> ---
>>  libc/sysdeps/linux/common/vfork.c |   20 +++++++++++++++++++-
>>  1 files changed, 19 insertions(+), 1 deletions(-)
>>
>> diff --git a/libc/sysdeps/linux/common/vfork.c 
>> b/libc/sysdeps/linux/common/vfork.c
>> index e7c9208..16f5f79 100644
>> --- a/libc/sysdeps/linux/common/vfork.c
>> +++ b/libc/sysdeps/linux/common/vfork.c
>> @@ -4,13 +4,31 @@
>>   * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
>>   */
>>
>> +#include <signal.h>
>>  #include <unistd.h>
>>  #include <sys/types.h>
>>  #include <sys/syscall.h>
>>
>>  extern __typeof(vfork) __vfork attribute_hidden;
>>
>> -#ifdef __NR_vfork
>> +#if defined(__NR_clone) && ! defined(__NR_vfork)
>> +pid_t __vfork(void)
>> +{
>> +     pid_t pid;
>> +     pid = INLINE_SYSCALL(clone, 4, CLONE_VFORK | CLONE_VM |
>> +             SIGCHLD, NULL, NULL, NULL);
>> +
>> +     if (pid<0) {
>> +             __set_errno(-pid);
>> +             return -1
>> +     }
>> +
>> +     return pid;
>> +}
>> +weak_alias(__vfork,vfork)
>> +libc_hidden_weak(vfork)
>
> This is not valid. clone will return twice, both in the parent and the
> child, but the child will already have clobbered the return address on
> the parent's stack due to sharing memory. Whether you use the clone
> syscall or the vfork syscall, the only way to implement vfork is from
> asm. If you want a generic C fallback, it should just behave as fork
> rather than as vfork.
>
> Rich
> _______________________________________________
> uClibc mailing list
> uClibc@uclibc.org
> http://lists.busybox.net/mailman/listinfo/uclibc

Hi Rich,

Thanks. I will implement it as fork() instead.

-- 
Regards,
Markos
_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to