473,666 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Urgent Help : fork()

AK
Hi everyone,

Please check out this query that I have in :
http://groups.google.com/group/proga...057ec587dd46b3

(its a bit long, thats why I am not typing it again; please do check
that link)

and please do respond... I know there are quite a number of members of
progav in here... This is one query I need resolved asap... So, please
do help...

Regards
AK
Feb 1 '08 #1
4 1691
In article <42************ *************** *******@q39g200 0hsf.googlegrou ps.com>,
AK <an***********@ gmail.comwrote:

>Please check out this query that I have in :
[a google group, not a usenet group]
>(its a bit long, thats why I am not typing it again; please do check
that link)
>and please do respond... I know there are quite a number of members of
progav in here... This is one query I need resolved asap...
fork() is off topic for comp.lang.c as it is an operating system
routine, not part of the C language.

[OT]

POSIX.1 1989 says,
The fork() function creates a new process. The new process
(child process) shall be an exact copy of the calling process
(parent process) except for the following:

(3) The child process has its own copy of the parent's file
descriptors. Each of the child's file descriptors refer to the
same open file description with the corresponding file
descriptor of the parent.

And -none- of the other differences enumerated have to do with I/O
(except for directory streams.)

Notice that bit about *exact* copy. And notice that file descriptions
are shared. From these two facts we can conclude that there is
an exact copy in each process of whatever was in the file buffers
before the fork() took place.

Your program prints from the file buffers in both processes, so
anything that was in the file buffers is going to be printed in both
processes.

If you need to have something in the file buffer output before
a fork(), you should be using fflush() before the fork().

[/OT]

Your program also ends its output with a printf string that does
not end in a '\n'. C leaves it as implementation defined as to
whether the last line of output will actually be output if the
last line does not end in '\n'. Your program might output the
last line on some systems but not output it on other systems.

--
This is a Usenet signature block. Please do not quote it when replying
to one of my postings.
http://en.wikipedia.org/wiki/Signature_block
Feb 1 '08 #2
AK
On Feb 1, 6:24*am, AK <anoopkamma...@ gmail.comwrote:
Hi everyone,

Please check out this query that I have in :http://groups.google.com/group/proga...ead/29057ec587...

(its a bit long, thats why I am not typing it again; please do check
that link)

and please do respond... I know there are quite a number of members of
progav in here... This is one query I need resolved asap... So, please
do help...

Regards
AK
BTW, I would prefer if you could post in the thread whose link is
provided above... But, I'l leave it up to you... To post in that
thread membership is required... So, for non-member of progav, you can
post here... For members of progav in here, please post in that
thread...

Regards
AK
Feb 1 '08 #3
AK <an***********@ gmail.comwrites :
Please check out this query that I have in :
http://groups.google.com/group/proga...057ec587dd46b3

(its a bit long, thats why I am not typing it again; please do check
that link)

and please do respond... I know there are quite a number of members of
progav in here... This is one query I need resolved asap... So, please
do help...
fork() is not a standard C function. Try asking in
comp.unix.progr ammer.

If you choose to post there, I suggest posting the article rather than
a link to it. It's not that long, and I presume you have some sort of
copy-and-paste facility available to you. In fact, you would have
been better off using copy-and-paste when you posted to progav; your
first #include directive is misspelled as "#Include". Re-typing code
is never a good idea; it's impossible to tell which errors were in
your original code, and which you introduced by re-typing it.

--
Keith Thompson (The_Other_Keit h) <ks***@mib.or g>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Feb 1 '08 #4
AK
On Feb 1, 7:40*am, Keith Thompson <ks...@mib.orgw rote:
AK <anoopkamma...@ gmail.comwrites :
Please check out this query that I have in :
http://groups.google.com/group/proga...ead/29057ec587...
(its a bit long, thats why I am not typing it again; please do check
that link)
and please do respond... I know there are quite a number of members of
progav in here... This is one query I need resolved asap... So, please
do help...

fork() is not a standard C function. *Try asking in
comp.unix.progr ammer.
Thank you very much...
If you choose to post there, I suggest posting the article rather than
a link to it. *It's not that long, and I presume you have some sort of
copy-and-paste facility available to you. *In fact, you would have
been better off using copy-and-paste when you posted to progav; your
first #include directive is misspelled as "#Include". *Re-typing code
is never a good idea; it's impossible to tell which errors were in
your original code, and which you introduced by re-typing it.
Please accept my apologies...

AK
Feb 2 '08 #5

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

Similar topics

4
5902
by: Benoit Dejean | last post by:
hello, i have a question about forking processes atm, i have some code which i want to rewrite os.system("cd ~ && exec " + cmd + " & disown") i want to remove this os.system call
2
1647
by: Rookie | last post by:
Hi, I have a program that fork()'s + execlp()'s two children. Later in the program I want to send a signal to the parent(SIGINT) . The parent's signal handler should then send signals to these two children. I am able to catch the signal in the parent - on catching this signal I invoke a function that sends kill(childPid,SIGINT) but the signal handler in the child doesn't seem to be getting invoked. Can someone please tell me why this is...
6
2394
by: shellcode | last post by:
the code: ------fork.c------ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> int main() {
27
5964
by: steve | last post by:
I was given the following code, and asked what the possible outputs could be. We're learning about processes and forking. int value; int main(){ int pid, number = 1; value = 2; pid = fork(); value = value + 2; number = number + 2;
11
8270
by: ramu | last post by:
Hi All, We know that a c function never returns more than one value. Then how come the fork() function returns two values? How it is implemented? Regards
1
5072
by: vduber6er | last post by:
Hi I want to have a wait page while the rest of the cgi does its process, but it seems like the wait page waits till everything is complete and never appears. I've tried forking twice already as suggested in a faq, but it still doesnt seem to work. Below is what I have done: pid = fork() if (pid == 0){ printf ("http://my.wait.page"); exit (100);
3
2713
by: thrillseekersforever | last post by:
The questions(A&B) are to fine no# of process running from the below codes. However, I couldn't decipher the solution. Will someone please throw some light on this? Thanks a lot!! A] void main() { .... pid1 = fork(); if (pid1) pid2 = fork(); .....
5
12223
by: JoeW | last post by:
Now before I go into detail I just want to say that this is purely for my own benefit and has no real world usage. I remember way back when the tool for *nix systems called forkbomb was created. I recently explained it to a friend of mine and at that time decided to see if I could replicate it in C#. I have created an application that, to me at least, mimics what fork would/should do on *nix/bsd systems. I know that fork spawns a new...
3
5678
by: CMorgan | last post by:
Hi everybody, I am experiencing an annoying problem with fork() and execv(). In my program I need to launch the "pppd" from a thread, so, I create a new process with fork and then in the child process I launch with execv the pppd to connect an embedded system to internet. The problem is that pppd fails. I have made two test program just to discard bugs (my applications is really big) and the result is that when I call execv from a...
0
8445
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8551
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.