How do I implement some logic that will allow me to duplicate the functionality on windows that I have on linux with fork() using python?
I'm specifically trying to execute a method on the SAPI Com component, while continuing the other logic in the main thread without blocking or waiting.
...
I've had some trouble forking of processes from a Perl CGI script when running on Windows. The main issue seems to be that 'fork' is emulated when running on windows, and doesn't actually seem to create a new process (just another thread in the current one). This means that web servers (like IIS) which are waiting for the process to fini...
Usually when I need to fork in C, I do something like this:
pid_t p = fork();
if(p == 0) { /* do child stuff */ }
else { /* do parent stuff and pray there wasn't an error */ }
It occured to me that I could ditch the extra variable and use:
if(fork() == 0) { /* child */ }
else { /* parent/pray */ }
Improper error handling aside, (wh...
I have a multithreded application in perl for which I have to rely on several non-thread safe modules, so I have been using fork()ed processes with kill() signals as a message passing interface.
The problem is that the signal handlers are a bit erratic (to say the least) and often end up with processes that get killed in inapropriate st...
Hi,
I have been trying to use the Perl utility/module "prove" as a test harness for some unit tests. The unit tests are a little more "system" than "unit" as I need to fork off some background processes as part of the test, Using the following...
sub SpinupMonitor{
my $base_dir = shift;
my $config = shift;
my $pid = fork();
...
Here's some Ruby code:
puts %x{ pstree #{$$} } # never forks
puts %x{ pstree '#{$$}' } # forks on amd64 only
On 32-bit Ubuntu Dapper, I get this output:
t.rb---pstree
t.rb---pstree
Which makes sense to me. But on 64-bit Ubuntu Hardy, I get this:
t.rb---sh---pstree
t.rb---pstree
What's being shown here is that Ruby forks befor...
I'm pretty sure one would do this using the os.plock(op) function, but I have no idea how. Also, if there's a better way, I'd be grateful to find out. Code snippets are very welcome. Thanks!
...
(Bear with me, I promise this gets to shebang and windows.)
I have about the simplest of WEBRick servers put together:
require 'webrick'
include WEBrick
s = HTTPServer.new(:Port=>2000, :DocumentRoot=>Dir::pwd)
s.start
Couldn't be simpler. This basic server does accept http connections (firefox, internet exploder, wget, TELENT) and ...
Suppose I have a process which spawns exactly one child process. Now when the parent process exits for whatever reason (normally or abnormally, by kill, ^C, assert failure or anything else) I want the child process to die. How to do that correctly?
Some similar question on stackoverflow:
(asked earlier) http://stackoverflow.com/ques...
Is it possible to do a "C like" fork in java, using an new independent jvm process ?
How?
...
I have a process x that I want to check for leaks with valgrind. The problem is that x is run by y, and y in turn is run by z. I can't run x standalone because y and z setup the environment for x, such as environment variables, command line switches, files needed by x etc.
Is there any way I can tell valgrind to run on z but to fol...
I'm writing a simple application in PHP which needs to occasionally carry out a fairly intensive set of MySQL updates. I don't particularly want this to cause a delay for the user, so I'm wondering about using pcntl_fork().
I'm not sure how this really works though: will the child process continue running after the parent process finis...
For quite a long time I've wanted to start a pet project that will aim in
time to become a web hosting control panel, but mainly focused on Python hosting --
meaning I would like to make a way for users to generate/start Django/
other frameworks projects right from the panel. I seemed to have
found the perfect tool to build my app with i...
EDIT: I've tagged this C in a hope to get more response. It's more the theory I'm interested in than a specific language implementation. So if you're a C coder please treat the following PHP as pseudo-code and feel free to respond with an answer written in C.
I am trying to speed up a PHP CLI script by having it execute its tasks in p...
Please consider the following fork()/SIGCHLD pseudo-code.
// main program excerpt
for (;;) {
if ( is_time_to_make_babies ) {
pid = fork();
if (pid == -1) {
/* fail */
} else if (pid == 0) {
/* child stuff */
print "child started"
exit
} else {
...
I have a program that writes to a FILE *cgiOut and just after it has written to the stream, I need to fork and run a background process. The trouble is that after the fork, the FILE * stream seems to flush out sometimes and I get duplicated output (after the fork, all open files are closed which I guess causes the buffers to be flushed)...
Is it possible for a parent process to start and stop a child (forked) process in Unix?
I want to implement a task scheduler (see here) which is able to run multiple processes at the same time which I believe requires either separate processes or threads.
How can I stop the execution of a child process and resume it after a given amoun...
I'm creating child processes with fork() in C/C++.
When the parent process ends (or is killed for some reason) I want all child processes to be killed as well.
Is that done automatically by the system? Or I have to do it myself?
Thanks.
Pre-existing similar questions:
http://stackoverflow.com/questions/269494/how-can-i-cause-a-chil...
I'd like to profile a program that forks and spawns several child processes. I want to see how much time is spent in some of the functions. What profiler can handle this job?
...
Hello,
I need to write a simple program: There will be a Parent and a few programs [children] (started via execl in Parent). Children communicate to one another in this way: Child I sens to Parent number J, Parent sends a message (something like -- "there is a message to you") to J, J send to Parent number K etc. etc.
And there is a pr...