473,396 Members | 1,886 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,396 software developers and data experts.

How to make "fork/wait" to WAIT longer?

Hi All,

I encountered a funny thing, and my code schetch as below:
#define READ 0
#define WRITE 1
int byteRead, status, pd[2];
char buff[100];

pipe(pd);

if (fork()) {
wait(&status);
byteRead = read(pd[READ], buff, 100);
buff[byteRead] = '\0';

} else {
close(WRITE);
dup(pd[WRITE]);
execl("./c_executable", argv1, argv2, NULL);

}

This piece of code works very well for years for me. However, when my
c_executable got slightly heavier work load (a number of hash and
processing, and tesed thoroghly), it was broken. While I replaced
c_executable with lighter work load, it worked again. I am puzzled:
does the fork/wait pair has a timeout that terminates the child
process of execl()? If not, why a heavier work load in child process
failed? If yes, how to make the wait() to WAIT longer? If it is not
the issue of timeout, what is the kicker behind?

Thanks!

Huey
Nov 14 '05 #1
1 2428
Huey <hu********@yahoo.com> wrote:
I encountered a funny thing, and my code schetch as below: #define READ 0
#define WRITE 1
int byteRead, status, pd[2];
char buff[100];

pipe(pd);

if (fork()) {
wait(&status);
byteRead = read(pd[READ], buff, 100);
buff[byteRead] = '\0';

} else {
close(WRITE);
dup(pd[WRITE]);
execl("./c_executable", argv1, argv2, NULL);

} This piece of code works very well for years for me. However, when my
c_executable got slightly heavier work load (a number of hash and
processing, and tesed thoroghly), it was broken. While I replaced
c_executable with lighter work load, it worked again. I am puzzled:
does the fork/wait pair has a timeout that terminates the child
process of execl()? If not, why a heavier work load in child process
failed? If yes, how to make the wait() to WAIT longer? If it is not
the issue of timeout, what is the kicker behind?


Sorry, but not a single of the functions you're using here is a
standard C function, making the question off-topic for clc. Please
ask this kind of questions e.g. comp.unix.programmer or a similar
group. It would also be reasonable to specify exactly what you
mean by "broken".

<OT>
No, fork()/wait() doesn't have any timeout. But there are some
strange things in your code, like calling close with an argument
of 1 (I guess you mean STDOUT_FILENO) or the arguments you pass to
execl() - is argv1 the name of the program? - etc. You're also mis-
using the pipe as a temporary buffer, which only works as long as
you don't try to write more bytes to it than the pipe length. And
there are several other things that could go wrong under certain
conditions.
</OT>
Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #2

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

Similar topics

1
by: Vivien Mallet | last post by:
Hello, I use popen2.Popen4 and I experienced problems with it. Let me show you with an example. The following script is called "lines" (it prints lines of 'X'): ---------------------...
2
by: Alexander Malkis | last post by:
What is the most portable way of "waiting for any key", i.e. the user who runs a program from the console should observe the following: - the program stops running - as soon as the user presses...
3
by: Aaron Queenan | last post by:
I have a form which performs some asynchronous code. I want to display a wait cursor when it starts, and hide the wait cursor when it has completed. This part works fairly well, using: ...
6
by: Terry Olsen | last post by:
I wanted to do this "inline" and not use a timer. Is there a better way? Do zipError = UnzipFile(datPath & zipFileName, datPath, False) If zipError = "Success" Then Exit Do UpdateStatus("File...
1
by: francescomoi | last post by:
Hi. I've developed a web application which handles a big ammount of data (acquired via web form), so it takes 30-40 seconds to show the result. In order to calm down users, I want to...
13
by: Vincent Delporte | last post by:
Hi I'm a Python newbie, and would like to rewrite this Perl scrip to be run with the Asterisk PBX: http://www.voip-info.org/wiki/view/Asterisk+NetCID Anyone knows if those lines are...
3
by: anders | last post by:
Hi! I have a problem converting a cgi-program to run on windows. The problem is that the CGI is collecting a lot of information (a orderhandlingsystem) and under unix the main process makes a...
4
by: louvino | last post by:
Hi, I have some links. When I click on one, a window opens but during the loading of this window, I would like the cursor is in state "wait" (using CSS : cursor : wait; ) Help me :-)
0
by: maheshnew2007 | last post by:
Hi, I have simple Ant's build.xml file, which contains fork="yes". build.xml file: <?xml version="1.0"?> <project name="test" default="compile" basedir="."> <property name="src"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.