Sponsored Content
Homework and Emergencies Homework & Coursework Questions fork system call understanding Post 302400296 by MrUser on Tuesday 2nd of March 2010 11:46:16 PM
Old 03-03-2010
Quote:
Originally Posted by karthigayan
Normally when we use fork the child will inherit the workspace of the parent.And also the child and the parent will run simultaneously.and any one can finish its process first.

Now come to your doubt,

Your while loop runs twice.Beginning of the loop you print some thing like " before fork():getpid()= 6010 " .When the first iteration a child process will get create.So the child and parent start to run simultaneously.So the statements can print in any order.

So the child have a provision the iterate the loop.So it will print the "before fork statement" .When the next iteration of the loop also the "bofore fork will get print.And the child process will get create and the appropriate statements will get print.

When the try for the next iteration the condition will get false.So it will come out.

Here :
One of the "before fork" statement is printed by the child process.

is there any technique to print the statements in the right order.
by right order i mean : to print the statements that come under same process rather than printing randomly.

i am unable to understand the process concept it self.
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

URGENT Help required regarding the use of FORK system call

I desperately wanted one of the UNIX Gurus to help me resolve my problem asap(I have to deliver the code to the client by Monday 08-oct). I have a file with around 5 million records (50 lakhs). Now my original process was taking around 30 hours to read the complete file, process each and every... (4 Replies)
Discussion started by: kkumar1975
4 Replies

2. Programming

Fork() system call time?

One more question. How can i calculate the time that system needs to make fork() system call? I need to make it with times function but i really don't know how. :( (2 Replies)
Discussion started by: davidoff
2 Replies

3. UNIX for Advanced & Expert Users

how to differentiate system call from library call

Hi, Ho do I differentiate system call from library call? for example if I am using chmod , how do I find out if it is a system call or library call? Thanks Muru (2 Replies)
Discussion started by: muru
2 Replies

4. UNIX for Dummies Questions & Answers

fork() system call

Can anyone explain me what really happens when a system call fork() is called ? I like to know what happens internally. Thanks in Advance. - Arun (1 Reply)
Discussion started by: arunviswanath
1 Replies

5. UNIX for Dummies Questions & Answers

fork system call

Hi folks, I want to know how this below program works? #include <stdio.h> int main() { printf("A\n"); fork(); printf("B\n"); fork(); fork(); printf("D\n"); fork(); printf("C\n"); } This is just for example. How this type of programs where fork is used many places, how the... (1 Reply)
Discussion started by: u_peerless
1 Replies

6. Shell Programming and Scripting

fork system call and \n

hi, i tried the following source codes: fork1.c: main() { printf("demo of fork\n"); fork(); printf("hello"); } output: demo of fork hello hello fork2.c: main() { printf("demo of fork"); (0 Replies)
Discussion started by: pnirmala
0 Replies

7. Programming

Problem with execution of fork system call if i use \n

hi all, i tried the following source codes: fork1.c: main() { printf("demo of fork\n"); fork(); printf("hello"); } output: demo of fork hello hello fork2.c: main() (3 Replies)
Discussion started by: pnirmala
3 Replies

8. UNIX for Advanced & Expert Users

Doubt with fork() system call

Hi I wrote a simple fork program to illustrate the fork() system cal. here it is #include<stdio.h> #include<sys/stat.h> #include<sys/types.h> main() { int flag; flag=fork(); if(flag==0) { printf("Child \n"); printf("Process id= %d\n",getpid()); ... (3 Replies)
Discussion started by: badsha6642
3 Replies

9. Shell Programming and Scripting

Help: how to call fork() in shell script? New to linux

Hi, I'm writing a shell script where I want to call fork(). However I wrote like this "var=fork()" in c style and got this error: "syntax error near unexpected token `(' " How could I call fork() in shell script? Thanks in advance. Duplicate Post - Continue Here - Please Do Not Cross Post... (0 Replies)
Discussion started by: Xiaoya
0 Replies

10. Ubuntu

Help: how to call fork() in shell script? New to linux

Hi, I'm writing a shell script where I want to call fork(). However I wrote like this "var=fork()" in c style and got this error: "syntax error near unexpected token `(' " How could I call fork() in shell script? Thanks in advance. (2 Replies)
Discussion started by: Xiaoya
2 Replies
CVSBUG(8)						      System Manager's Manual							 CVSBUG(8)

NAME
cvsbug - send problem report (PR) about CVS to a central support site SYNOPSIS
cvsbug [ site ] [ -f problem-report ] [ -t mail-address ] [ -P ] [ -L ] [ --request-id ] [ -v ] DESCRIPTION
cvsbug is a tool used to submit problem reports (PRs) to a central support site. In most cases the correct site will be the default. This argument indicates the support site which is responsible for the category of problem involved. Some sites may use a local address as a default. site values are defined by using the aliases(5). cvsbug invokes an editor on a problem report template (after trying to fill in some fields with reasonable default values). When you exit the editor, cvsbug sends the completed form to the Problem Report Management System (GNATS) at a central support site. At the support site, the PR is assigned a unique number and is stored in the GNATS database according to its category and submitter-id. GNATS automati- cally replies with an acknowledgement, citing the category and the PR number. To ensure that a PR is handled promptly, it should contain your (unique) submitter-id and one of the available categories to identify the problem area. (Use `cvsbug -L' to see a list of categories.) The cvsbug template at your site should already be customized with your submitter-id (running `install-sid submitter-id' to accomplish this is part of the installation procedures for cvsbug). If this hasn't been done, see your system administrator for your submitter-id, or request one from your support site by invoking `cvsbug --request-id'. If your site does not distinguish between different user sites, or if you are not affiliated with the support site, use `net' for this field. The more precise your problem description and the more complete your information, the faster your support team can solve your problems. OPTIONS
-f problem-report specify a file (problem-report) which already contains a complete problem report. cvsbug sends the contents of the file without invoking the editor. If the value for problem-report is `-', then cvsbug reads from standard input. -t mail-address Change mail address at the support site for problem reports. The default mail-address is the address used for the default site. Use the site argument rather than this option in nearly all cases. -P print the form specified by the environment variable PR_FORM on standard output. If PR_FORM is not set, print the standard blank PR template. No mail is sent. -L print the list of available categories. No mail is sent. --request-id sends mail to the default support site, or site if specified, with a request for your submitter-id. If you are not affiliated with site, use a submitter-id of net'. -v Display the cvsbug version number. Note: use cvsbug to submit problem reports rather than mailing them directly. Using both the template and cvsbug itself will help ensure all necessary information will reach the support site. ENVIRONMENT
The environment variable EDITOR specifies the editor to invoke on the template. default: vi If the environment variable PR_FORM is set, then its value is used as the file name of the template for your problem-report editing ses- sion. You can use this to start with a partially completed form (for example, a form with the identification fields already completed). HOW TO FILL OUT A PROBLEM REPORT
Problem reports have to be in a particular form so that a program can easily manage them. Please remember the following guidelines: o describe only one problem with each problem report. o For follow-up mail, use the same subject line as the one in the automatic acknowledgement. It consists of category, PR number and the original synopsis line. This allows the support site to relate several mail messages to a particular PR and to record them automati- cally. o Please try to be as accurate as possible in the subject and/or synopsis line. o The subject and the synopsis line are not confidential. This is because open-bugs lists are compiled from them. Avoid confidential information there. See the GNU Info file cvsbug.info or the document Reporting Problems With cvsbug for detailed information on reporting problems HOW TO SUBMIT TEST CASES, CODE, ETC. Submit small code samples with the PR. Contact the support site for instructions on submitting larger test cases and problematic source code. FILES
/tmp/p$$ copy of PR used in editing session /tmp/pf$$ copy of empty PR form, for testing purposes /tmp/pbad$$ file for rejected PRs INSTALLATION AND CONFIGURATION
See INSTALL for installation instructions. SEE ALSO
gnats(l), query-pr(1), edit-pr(1), gnats(8), queue-pr(8), at-pr(8), mkcat(8), mkdist(8). AUTHORS
Jeffrey Osier, Brendan Kehoe, Jason Merrill, Heinz G. Seidl (Cygnus Support) COPYING
Copyright (c) 1992, 1993 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. February 1993 xVERSIONx CVSBUG(8)
All times are GMT -4. The time now is 06:35 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy