On Sat, Oct 31, 2009 at 4:10 PM, Sean Chittenden <[email protected]> wrote: >> Folks >> Whats the best way to spawn an external process with wt on >> freebsd. When i use system() even with fork() and wait() the wt >> server locks up and continues to say "loading". Ive tried using >> "daemon" command to just throw my process in the background and it >> still wont work. I would like to use the progress indicator and show >> the status if i could. Im running wt with boost threads. I grabbed >> the latest verson about 2 months ago. Thanks for any help. > > Generally speaking? Avoid fork'ing from Wt if you can and have a > different process do it for you, then capture the output. > > This isn't a FreeBSD specific question. The problem you're likely > running in to is you're not setting fork handler for pthreads > (pthread_atfork(3)) and aren't cleaning up existing Wt resources (such > as threads before the exec). Have you attached gdb to your Wt process > to figure out what's going on when it blocks? Are you installing per- > thread signal handlers and catching SIGCHLDs? > > IMHO, your best bet is to use fork(2) early on in your Wt startup > process and have it exist as a dedicated process that you message from > Wt, and have it fork(2) + exec(2) your new child commands. Have the > child manager pass a fd resource back to your Wt process (via dup(2), > see Steven's for examples) and have it check the status of the fd with > 0 byte, non-blocking writes to the fd.
I am curious, on a Windows system, to spawn a new process you generally use CreateProcess, which returns immediately (it just posts a message to the kernel that the kernel handles shortly. You get back a handle and a few other things. If you want to wait for the process you started to quit then you can just basically WaitForEvent(theHandle), which pauses until the other process terminates, then using the handle you can get things like closing code and stuff like that (or during run you can hook its cin/cout and so forth). Admittedly I originally come from the DOS world long long ago, but it seems rather heavyweight to me to fork an entire process just to spawn another process, certainly there is a better way then that? ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
