Date: Mon, 22 Mar 1999 08:26:01 -0600 From: "Richard Seaman, Jr." <dick@tar.com> To: Peter Wemm <peter@netplex.com.au> Cc: Matthew Dillon <dillon@apollo.backplane.com>, Brian Feldman <green@unixhelp.org>, "John S. Dyson" <dyson@iquest.net>, freebsd-current@FreeBSD.ORG Subject: Re: rfork() Message-ID: <19990322082601.L32029@tar.com> In-Reply-To: <199903220334.LAA52679@spinner.netplex.com.au>; from Peter Wemm on Mon, Mar 22, 1999 at 11:34:25AM %2B0800 References: <199903211721.JAA13495@apollo.backplane.com> <199903220334.LAA52679@spinner.netplex.com.au>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Mar 22, 1999 at 11:34:25AM +0800, Peter Wemm wrote: > Doing clone() in libc that calls rfork(2) and doing all the stack setup > should be pretty easy.. (Richard has done it already, yes?) Its in package at http://lt.tar.com/linuxthreads.tar.gz . If anyone wants to grab it out of there an put it into shape to commit it, be my guest. > On the other > hand, the linux emulator needs it so there's a counter-argument for making > it a proper syscall outright. Leaving the rfork(2) stuff unmolested and at > least resembling it's plan9 origins probably has some merit - adding extra > arguments would mess that up. I) clone syscall --------------------- The linux emulator needs (and has) a clone syscall: int linux_clone(int flags, void *stack) The value of an exit signal is passed in the lower 8 bits of the flags argument, the linux counterparts to the FreeBSD RF* flags are passed in the balance of the flags argument. I haven't seen or heard of a linux app that calls the clone syscall directly. I know of two "apps", linuxthreads and the linux version of WINE, that call the linux glibc version of clone (see below), which is a wrapper for the syscall. The only thing that the linux syscall does, that can't be done easily in FreeBSD using rfork and an appropriate wrapper to rfork, is pass in the exit signal. rfork does have a flag to set an exit signal of SIGUSR1, but it does not conveniently take a parameter to set it more flexibly. OTOH, the only FreeBSD app I know of that actually sets an exit signal other that the default SIGCHLD, is the linuxthreads port noted above. I'm not sure there is really a need for a "clone" syscall at this point, but if you wanted it, you could just copy the linux_clone code in linux_misc.c . You would have to decide if you want the flags parameter to take the linux flags values, or FreeBSD flags (the emulator has to take the linux values, obviously). My vote: don't bother with a syscall until there's a demonstrated need. II) clone in libc ----------------- Linux glibc has a clone call wrapper for the clone syscall, defined as: int clone (int (*fn) (void *arg), void *stack, int flags, void *arg) The stack and flags are passed directly to the clone syscall, and the fn(arg) is the user function the cloned process should execute. Its easy enough to implement this in FreeBSD as a wrapper for rfork. If you want to facilitate porting linux code, you would want the flags argument to take linux flags, which would then be translated into their FreeBSD counterparts before rfork is call. This is what the code in the linuxthreads port does, and you are welcome to commit it. The only issue here is whether people need to port linux code that calls clone directly. As noted above, the only code I know of that calls clone directly is WINE and linuxthreads. All the rest of the code uses pthread_create, which only indirectly calls clone. My vote: I haven't seen the need, but if there is one, lets do it. III) libc rfork wrapper ----------------------- It probably would be nice to have a libc rfork wrapper that grafts a stack and a user function onto the rfork'd child process. But, it should probably take FreeBSD flags, and there's no reason to call it "clone". John Dyson's thr_fork is one such implementation. Luoqi Chen posted another variation to either -hackers or -current maybe 6-9 months ago. Matt Dillon just posted yet another variation. Or, the linuxthreads port has a variation of the clone call that has the same API as the linux clone call, but takes FreeBSD flags (see clone.S). My vote: its worth doing, but not a top priority. The main issue is to decide what interface would be most convenient. Its not a top priority since the code already exists for those (rare) cases where someone really needs it. And, lets not call it "clone". -- Richard Seaman, Jr. email: dick@tar.com 5182 N. Maple Lane phone: 414-367-5450 Chenequa WI 53058 fax: 414-367-5852 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990322082601.L32029>