473,324 Members | 2,193 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Forking !

I sure hope this question is relevent to comp.lang.c++ . I have my
doubt but here I go!

I have very code that do as follows
pid_t pId = fork();

//Very large body of code
codeline1();
codeline2();
codeline3();
//etc etc etc

if (pId == 0) {

//child codes

}else if (pId < 0 ) {

//some error codes

}else {

//parent codes

}

My question is codeline1(), codeline2() and codeline3(). Are they
executed by the parent children or both?

Any comments?

Thanks In Advance!
Jan 17 '08 #1
2 1310
ha*********@gmail.com a écrit :
I sure hope this question is relevent to comp.lang.c++ . I have my
doubt but here I go!
It isn't. fork() is POSIX specific.
>
I have very code that do as follows
pid_t pId = fork();

//Very large body of code
codeline1();
codeline2();
codeline3();
//etc etc etc

if (pId == 0) {

//child codes

}else if (pId < 0 ) {

//some error codes

}else {

//parent codes

}

My question is codeline1(), codeline2() and codeline3(). Are they
executed by the parent children or both?
Both.
>
Any comments?
I find it strange that you check for the error case so late (usually a
memory matter, so it is rather important) and I would also question the
interest of having instructions execution duplicated in the fater and
the child when you don't know if it successful or in with process you are.

Michael
Jan 17 '08 #2
Any comments?

I find it strange that you check for the error case so late (usually a
memory matter, so it is rather important) and I would also question the
interest of having instructions execution duplicated in the fater and
the child when you don't know if it successful or in with process you are.

Michael
Thanks for the reply. I am maintaining old codes.

If it is executed by both than I have a reason to cry foul and point
out that it is a bug.

Thanks again!
Jan 17 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Hopeless A | last post by:
We are attempting to fork a php script into a background php script and have the first scrip continue to completion. Is this even possible in the windows version of php? We have used the many code...
0
by: Eric S. Johansson | last post by:
I was working on a filter for postfix and instead of using the "fork a new python process on every message" route, I decided to use the SMTP interface instead and try forking after having started...
1
by: SRam | last post by:
How to create a threaded process in Perl. I need explanation for this code from Advanced Perl Programming.... # Forking server use IO::Socket; $SIG{CHLD} = sub {wait ()}; $main_sock = new...
0
by: SRam | last post by:
I a writing Forking Server for a Small application.. This is code for multiplexing my $listen = IO::Socket::INET->new(Proto => 'tcp',LocalPort => 2323, Listen => 1, Reuse => 1) or die $!; ...
1
by: Matt Stevens | last post by:
Hello, I'm having some trouble trying to get this simple forking http daemon to work, when I run it everything seems to run ok and then when I try to connect to it with a browser on another...
0
by: Roy Smith | last post by:
I'm writing a network application in C++, using CppUnit for unit testing. I'm thinking of forking a subprocess to run tcpdump in some of my unit tests to watch actual packets on the wire as they...
3
by: felixfix | last post by:
Hi all, I am just wondering if something is wrong with my program. What it bascially does is to output a fibonacci sequence base on the command-line output. If I give a 5, it will generate the...
3
by: czajnik | last post by:
Hi! I'm quite new to Python development. Can someone advise me a framework useful for building (pre-)forking or threaded TCP servers, other than SocketServer ? I've seen source code of a few...
10
by: qwertycat | last post by:
I'm new to multi-process programming, should one avoid forking children from children of a parent? I'd like to spawn 10 children from the parent and each of those children spawns another 5...
2
by: Gilles Ganault | last post by:
Hello I'd like to rewrite the following Perl script in Python: http://www.voip-info.org/wiki/view/Asterisk+NetCID It seems like the following doesn't actually fork, so Asterisk is stuck...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.