SlideShare a Scribd company logo
1 of 4
Download to read offline
//Tested on ubuntu,Linux
#include
#include
#include
#include //for getpid()
#include //for wait
/*Main function start*/
void main(int argc, char *argv[])
{
pid_t pid;//storing process id
int i;
int status = 0;
/*Start for loop*/
for (i = 1; i < argc; i++)
{
pid=fork();//forking process
if (pid == 0)// child process
{
/*Printing file name and process Id*/
printf("Filename: %s PID: %d ",argv[i],getpid());
return;
}else{
pid = wait(&status);//waiting for child process to complete
}
}/*End for loop*/
printf("done! ");
}
/*Main function End*/
/************output**************/
gopal@gopal:~/Desktop/chegg$ gcc fork.c -o program2
gopal@gopal:~/Desktop/chegg$ ./program2 *.c
Filename: Calculator.c PID: 22742
Filename: char2dArray.c PID: 22743
Filename: client.c PID: 22744
Filename: commandLine.c PID: 22745
Filename: directory.c PID: 22746
Filename: dLinkedList.c PID: 22747
Filename: duplicateArrayRemove.c PID: 22748
Filename: fileReading.c PID: 22749
Filename: fork.c PID: 22750
Filename: hailstone.c PID: 22751
Filename: hello.c PID: 22752
Filename: interest.c PID: 22753
Filename: inventory.c PID: 22754
Filename: largeNumber.c PID: 22755
Filename: lscat.c PID: 22756
Filename: main.c PID: 22757
Filename: nestedLoop.c PID: 22758
Filename: Person.c PID: 22759
Filename: prime.c PID: 22760
Filename: railCiper.c PID: 22761
Filename: random.c PID: 22762
Filename: readFile.c PID: 22763
Filename: rollercoaster.c PID: 22764
Filename: server.c PID: 22765
Filename: simple-cat.c PID: 22766
Filename: simple-ls.c PID: 22767
Filename: sumRecursion.c PID: 22768
Filename: Tree.c PID: 22769
done!
gopal@gopal:~/Desktop/chegg$ ./program2 Person.c server.c
Filename: Person.c PID: 22814
Filename: server.c PID: 22815
done!
Thanks a lot
Solution
//Tested on ubuntu,Linux
#include
#include
#include
#include //for getpid()
#include //for wait
/*Main function start*/
void main(int argc, char *argv[])
{
pid_t pid;//storing process id
int i;
int status = 0;
/*Start for loop*/
for (i = 1; i < argc; i++)
{
pid=fork();//forking process
if (pid == 0)// child process
{
/*Printing file name and process Id*/
printf("Filename: %s PID: %d ",argv[i],getpid());
return;
}else{
pid = wait(&status);//waiting for child process to complete
}
}/*End for loop*/
printf("done! ");
}
/*Main function End*/
/************output**************/
gopal@gopal:~/Desktop/chegg$ gcc fork.c -o program2
gopal@gopal:~/Desktop/chegg$ ./program2 *.c
Filename: Calculator.c PID: 22742
Filename: char2dArray.c PID: 22743
Filename: client.c PID: 22744
Filename: commandLine.c PID: 22745
Filename: directory.c PID: 22746
Filename: dLinkedList.c PID: 22747
Filename: duplicateArrayRemove.c PID: 22748
Filename: fileReading.c PID: 22749
Filename: fork.c PID: 22750
Filename: hailstone.c PID: 22751
Filename: hello.c PID: 22752
Filename: interest.c PID: 22753
Filename: inventory.c PID: 22754
Filename: largeNumber.c PID: 22755
Filename: lscat.c PID: 22756
Filename: main.c PID: 22757
Filename: nestedLoop.c PID: 22758
Filename: Person.c PID: 22759
Filename: prime.c PID: 22760
Filename: railCiper.c PID: 22761
Filename: random.c PID: 22762
Filename: readFile.c PID: 22763
Filename: rollercoaster.c PID: 22764
Filename: server.c PID: 22765
Filename: simple-cat.c PID: 22766
Filename: simple-ls.c PID: 22767
Filename: sumRecursion.c PID: 22768
Filename: Tree.c PID: 22769
done!
gopal@gopal:~/Desktop/chegg$ ./program2 Person.c server.c
Filename: Person.c PID: 22814
Filename: server.c PID: 22815
done!
Thanks a lot

More Related Content

Similar to Tested on ubuntu,Linux#include stdio.h #include string.h.pdf

httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxadampcarr67227
 
How to recognise that the user has just uninstalled your android app droidc...
How to recognise that the user has just uninstalled your android app   droidc...How to recognise that the user has just uninstalled your android app   droidc...
How to recognise that the user has just uninstalled your android app droidc...Przemek Jakubczyk
 
How to recognise that the user has just uninstalled your android app
How to recognise that the user has just uninstalled your android appHow to recognise that the user has just uninstalled your android app
How to recognise that the user has just uninstalled your android appPrzemek Jakubczyk
 
assign4assign4_part1bonnie.c This is a file system ben.docx
assign4assign4_part1bonnie.c  This is a file system ben.docxassign4assign4_part1bonnie.c  This is a file system ben.docx
assign4assign4_part1bonnie.c This is a file system ben.docxfestockton
 
UNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptxUNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptxraunakkumar290158
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxRutujaTandalwade
 
Unix And C
Unix And CUnix And C
Unix And CDr.Ravi
 
Unit 8
Unit 8Unit 8
Unit 8siddr
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptxDiptoRoy21
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes
 
Thread介紹
Thread介紹Thread介紹
Thread介紹Jack Chen
 
Cell processor lab
Cell processor labCell processor lab
Cell processor labcoolmirza143
 

Similar to Tested on ubuntu,Linux#include stdio.h #include string.h.pdf (20)

httplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docxhttplinux.die.netman3execfork() creates a new process by.docx
httplinux.die.netman3execfork() creates a new process by.docx
 
How to recognise that the user has just uninstalled your android app droidc...
How to recognise that the user has just uninstalled your android app   droidc...How to recognise that the user has just uninstalled your android app   droidc...
How to recognise that the user has just uninstalled your android app droidc...
 
How to recognise that the user has just uninstalled your android app
How to recognise that the user has just uninstalled your android appHow to recognise that the user has just uninstalled your android app
How to recognise that the user has just uninstalled your android app
 
assign4assign4_part1bonnie.c This is a file system ben.docx
assign4assign4_part1bonnie.c  This is a file system ben.docxassign4assign4_part1bonnie.c  This is a file system ben.docx
assign4assign4_part1bonnie.c This is a file system ben.docx
 
UNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptxUNIX_Process Control_Module3.pptx
UNIX_Process Control_Module3.pptx
 
L8 file
L8 fileL8 file
L8 file
 
Os lab final
Os lab finalOs lab final
Os lab final
 
File & Exception Handling in C++.pptx
File & Exception Handling in C++.pptxFile & Exception Handling in C++.pptx
File & Exception Handling in C++.pptx
 
Process management
Process managementProcess management
Process management
 
Unix And C
Unix And CUnix And C
Unix And C
 
Unit 8
Unit 8Unit 8
Unit 8
 
Lecture_Slide_4.pptx
Lecture_Slide_4.pptxLecture_Slide_4.pptx
Lecture_Slide_4.pptx
 
Npc14
Npc14Npc14
Npc14
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
Supermarket
SupermarketSupermarket
Supermarket
 
Geeks Anonymes - Le langage Go
Geeks Anonymes - Le langage GoGeeks Anonymes - Le langage Go
Geeks Anonymes - Le langage Go
 
Thread介紹
Thread介紹Thread介紹
Thread介紹
 
Golang workshop
Golang workshopGolang workshop
Golang workshop
 
Cell processor lab
Cell processor labCell processor lab
Cell processor lab
 
Sbaw091006
Sbaw091006Sbaw091006
Sbaw091006
 

More from aquacare2008

1 ans ErgonomicsDefinition Ergonomics defines from two Greek .pdf
1 ans ErgonomicsDefinition  Ergonomics defines from two Greek .pdf1 ans ErgonomicsDefinition  Ergonomics defines from two Greek .pdf
1 ans ErgonomicsDefinition Ergonomics defines from two Greek .pdfaquacare2008
 
a) Binds to- dissociate from - operator - promoter.When the lactos.pdf
a) Binds to- dissociate from - operator - promoter.When the lactos.pdfa) Binds to- dissociate from - operator - promoter.When the lactos.pdf
a) Binds to- dissociate from - operator - promoter.When the lactos.pdfaquacare2008
 
A gastric or stomach ulcer is regularly caused by an infection with .pdf
A gastric or stomach ulcer is regularly caused by an infection with .pdfA gastric or stomach ulcer is regularly caused by an infection with .pdf
A gastric or stomach ulcer is regularly caused by an infection with .pdfaquacare2008
 
A packet is first of all considered to be as trhe unit of data that .pdf
A packet is first of all considered to be as trhe unit of data that .pdfA packet is first of all considered to be as trhe unit of data that .pdf
A packet is first of all considered to be as trhe unit of data that .pdfaquacare2008
 
The Citric Acid Cycle is the single most effectiv.pdf
                     The Citric Acid Cycle is the single most effectiv.pdf                     The Citric Acid Cycle is the single most effectiv.pdf
The Citric Acid Cycle is the single most effectiv.pdfaquacare2008
 
1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf
1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf
1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdfaquacare2008
 
Compco Systems Total payout next year = 4.86 billion.pdf
    Compco Systems               Total payout next year = 4.86 billion.pdf    Compco Systems               Total payout next year = 4.86 billion.pdf
Compco Systems Total payout next year = 4.86 billion.pdfaquacare2008
 
Most scientists suspect that the reason of the dramatic crash of pop.pdf
  Most scientists suspect that the reason of the dramatic crash of pop.pdf  Most scientists suspect that the reason of the dramatic crash of pop.pdf
Most scientists suspect that the reason of the dramatic crash of pop.pdfaquacare2008
 
1) The first abstract suggest that predator prey relationship outc.pdf
1) The first abstract suggest that predator  prey relationship outc.pdf1) The first abstract suggest that predator  prey relationship outc.pdf
1) The first abstract suggest that predator prey relationship outc.pdfaquacare2008
 
Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf
                     Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf                     Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf
Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdfaquacare2008
 
Multiplicity refers to the number of signals in t.pdf
                     Multiplicity refers to the number of signals in t.pdf                     Multiplicity refers to the number of signals in t.pdf
Multiplicity refers to the number of signals in t.pdfaquacare2008
 
Three major parts of brainstem are midbrain, pons and medulla oblong.pdf
Three major parts of brainstem are midbrain, pons and medulla oblong.pdfThree major parts of brainstem are midbrain, pons and medulla oblong.pdf
Three major parts of brainstem are midbrain, pons and medulla oblong.pdfaquacare2008
 
The question is a little unclear. Im going to guess that there are.pdf
The question is a little unclear. Im going to guess that there are.pdfThe question is a little unclear. Im going to guess that there are.pdf
The question is a little unclear. Im going to guess that there are.pdfaquacare2008
 
The future value of investment is calculated as followsFuture valu.pdf
The future value of investment is calculated as followsFuture valu.pdfThe future value of investment is calculated as followsFuture valu.pdf
The future value of investment is calculated as followsFuture valu.pdfaquacare2008
 
The patient is susceptive to pneumococcal bacteremia while she was t.pdf
The patient is susceptive to pneumococcal bacteremia while she was t.pdfThe patient is susceptive to pneumococcal bacteremia while she was t.pdf
The patient is susceptive to pneumococcal bacteremia while she was t.pdfaquacare2008
 
The Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdf
The Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdfThe Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdf
The Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdfaquacare2008
 
SRP Signal recognition particle. The signal recognition particle (S.pdf
SRP Signal recognition particle. The signal recognition particle (S.pdfSRP Signal recognition particle. The signal recognition particle (S.pdf
SRP Signal recognition particle. The signal recognition particle (S.pdfaquacare2008
 
Some of the various financial position found in most hotels areRe.pdf
Some of the various financial position found in most hotels areRe.pdfSome of the various financial position found in most hotels areRe.pdf
Some of the various financial position found in most hotels areRe.pdfaquacare2008
 
Retroactive interference when you learn some new things this memory.pdf
Retroactive interference when you learn some new things this memory.pdfRetroactive interference when you learn some new things this memory.pdf
Retroactive interference when you learn some new things this memory.pdfaquacare2008
 
Ques-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdf
Ques-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdfQues-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdf
Ques-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdfaquacare2008
 

More from aquacare2008 (20)

1 ans ErgonomicsDefinition Ergonomics defines from two Greek .pdf
1 ans ErgonomicsDefinition  Ergonomics defines from two Greek .pdf1 ans ErgonomicsDefinition  Ergonomics defines from two Greek .pdf
1 ans ErgonomicsDefinition Ergonomics defines from two Greek .pdf
 
a) Binds to- dissociate from - operator - promoter.When the lactos.pdf
a) Binds to- dissociate from - operator - promoter.When the lactos.pdfa) Binds to- dissociate from - operator - promoter.When the lactos.pdf
a) Binds to- dissociate from - operator - promoter.When the lactos.pdf
 
A gastric or stomach ulcer is regularly caused by an infection with .pdf
A gastric or stomach ulcer is regularly caused by an infection with .pdfA gastric or stomach ulcer is regularly caused by an infection with .pdf
A gastric or stomach ulcer is regularly caused by an infection with .pdf
 
A packet is first of all considered to be as trhe unit of data that .pdf
A packet is first of all considered to be as trhe unit of data that .pdfA packet is first of all considered to be as trhe unit of data that .pdf
A packet is first of all considered to be as trhe unit of data that .pdf
 
The Citric Acid Cycle is the single most effectiv.pdf
                     The Citric Acid Cycle is the single most effectiv.pdf                     The Citric Acid Cycle is the single most effectiv.pdf
The Citric Acid Cycle is the single most effectiv.pdf
 
1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf
1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf
1.salbutamol sulfate (Ventolin)- the molecular formula of salbutamo.pdf
 
Compco Systems Total payout next year = 4.86 billion.pdf
    Compco Systems               Total payout next year = 4.86 billion.pdf    Compco Systems               Total payout next year = 4.86 billion.pdf
Compco Systems Total payout next year = 4.86 billion.pdf
 
Most scientists suspect that the reason of the dramatic crash of pop.pdf
  Most scientists suspect that the reason of the dramatic crash of pop.pdf  Most scientists suspect that the reason of the dramatic crash of pop.pdf
Most scientists suspect that the reason of the dramatic crash of pop.pdf
 
1) The first abstract suggest that predator prey relationship outc.pdf
1) The first abstract suggest that predator  prey relationship outc.pdf1) The first abstract suggest that predator  prey relationship outc.pdf
1) The first abstract suggest that predator prey relationship outc.pdf
 
Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf
                     Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf                     Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf
Sodium bicarbonate (Na+HCO3- ) is mildly alkaline.pdf
 
Multiplicity refers to the number of signals in t.pdf
                     Multiplicity refers to the number of signals in t.pdf                     Multiplicity refers to the number of signals in t.pdf
Multiplicity refers to the number of signals in t.pdf
 
Three major parts of brainstem are midbrain, pons and medulla oblong.pdf
Three major parts of brainstem are midbrain, pons and medulla oblong.pdfThree major parts of brainstem are midbrain, pons and medulla oblong.pdf
Three major parts of brainstem are midbrain, pons and medulla oblong.pdf
 
The question is a little unclear. Im going to guess that there are.pdf
The question is a little unclear. Im going to guess that there are.pdfThe question is a little unclear. Im going to guess that there are.pdf
The question is a little unclear. Im going to guess that there are.pdf
 
The future value of investment is calculated as followsFuture valu.pdf
The future value of investment is calculated as followsFuture valu.pdfThe future value of investment is calculated as followsFuture valu.pdf
The future value of investment is calculated as followsFuture valu.pdf
 
The patient is susceptive to pneumococcal bacteremia while she was t.pdf
The patient is susceptive to pneumococcal bacteremia while she was t.pdfThe patient is susceptive to pneumococcal bacteremia while she was t.pdf
The patient is susceptive to pneumococcal bacteremia while she was t.pdf
 
The Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdf
The Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdfThe Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdf
The Enthalpy of fusion, or heat of fusion is the change in enthalpy .pdf
 
SRP Signal recognition particle. The signal recognition particle (S.pdf
SRP Signal recognition particle. The signal recognition particle (S.pdfSRP Signal recognition particle. The signal recognition particle (S.pdf
SRP Signal recognition particle. The signal recognition particle (S.pdf
 
Some of the various financial position found in most hotels areRe.pdf
Some of the various financial position found in most hotels areRe.pdfSome of the various financial position found in most hotels areRe.pdf
Some of the various financial position found in most hotels areRe.pdf
 
Retroactive interference when you learn some new things this memory.pdf
Retroactive interference when you learn some new things this memory.pdfRetroactive interference when you learn some new things this memory.pdf
Retroactive interference when you learn some new things this memory.pdf
 
Ques-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdf
Ques-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdfQues-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdf
Ques-7Viruses contain DNA (deoxyribonucleic acid) or RNA (ribonuc.pdf
 

Recently uploaded

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 

Recently uploaded (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 

Tested on ubuntu,Linux#include stdio.h #include string.h.pdf

  • 1. //Tested on ubuntu,Linux #include #include #include #include //for getpid() #include //for wait /*Main function start*/ void main(int argc, char *argv[]) { pid_t pid;//storing process id int i; int status = 0; /*Start for loop*/ for (i = 1; i < argc; i++) { pid=fork();//forking process if (pid == 0)// child process { /*Printing file name and process Id*/ printf("Filename: %s PID: %d ",argv[i],getpid()); return; }else{ pid = wait(&status);//waiting for child process to complete } }/*End for loop*/ printf("done! "); } /*Main function End*/ /************output**************/ gopal@gopal:~/Desktop/chegg$ gcc fork.c -o program2 gopal@gopal:~/Desktop/chegg$ ./program2 *.c Filename: Calculator.c PID: 22742 Filename: char2dArray.c PID: 22743 Filename: client.c PID: 22744 Filename: commandLine.c PID: 22745
  • 2. Filename: directory.c PID: 22746 Filename: dLinkedList.c PID: 22747 Filename: duplicateArrayRemove.c PID: 22748 Filename: fileReading.c PID: 22749 Filename: fork.c PID: 22750 Filename: hailstone.c PID: 22751 Filename: hello.c PID: 22752 Filename: interest.c PID: 22753 Filename: inventory.c PID: 22754 Filename: largeNumber.c PID: 22755 Filename: lscat.c PID: 22756 Filename: main.c PID: 22757 Filename: nestedLoop.c PID: 22758 Filename: Person.c PID: 22759 Filename: prime.c PID: 22760 Filename: railCiper.c PID: 22761 Filename: random.c PID: 22762 Filename: readFile.c PID: 22763 Filename: rollercoaster.c PID: 22764 Filename: server.c PID: 22765 Filename: simple-cat.c PID: 22766 Filename: simple-ls.c PID: 22767 Filename: sumRecursion.c PID: 22768 Filename: Tree.c PID: 22769 done! gopal@gopal:~/Desktop/chegg$ ./program2 Person.c server.c Filename: Person.c PID: 22814 Filename: server.c PID: 22815 done! Thanks a lot Solution //Tested on ubuntu,Linux #include #include
  • 3. #include #include //for getpid() #include //for wait /*Main function start*/ void main(int argc, char *argv[]) { pid_t pid;//storing process id int i; int status = 0; /*Start for loop*/ for (i = 1; i < argc; i++) { pid=fork();//forking process if (pid == 0)// child process { /*Printing file name and process Id*/ printf("Filename: %s PID: %d ",argv[i],getpid()); return; }else{ pid = wait(&status);//waiting for child process to complete } }/*End for loop*/ printf("done! "); } /*Main function End*/ /************output**************/ gopal@gopal:~/Desktop/chegg$ gcc fork.c -o program2 gopal@gopal:~/Desktop/chegg$ ./program2 *.c Filename: Calculator.c PID: 22742 Filename: char2dArray.c PID: 22743 Filename: client.c PID: 22744 Filename: commandLine.c PID: 22745 Filename: directory.c PID: 22746 Filename: dLinkedList.c PID: 22747 Filename: duplicateArrayRemove.c PID: 22748 Filename: fileReading.c PID: 22749
  • 4. Filename: fork.c PID: 22750 Filename: hailstone.c PID: 22751 Filename: hello.c PID: 22752 Filename: interest.c PID: 22753 Filename: inventory.c PID: 22754 Filename: largeNumber.c PID: 22755 Filename: lscat.c PID: 22756 Filename: main.c PID: 22757 Filename: nestedLoop.c PID: 22758 Filename: Person.c PID: 22759 Filename: prime.c PID: 22760 Filename: railCiper.c PID: 22761 Filename: random.c PID: 22762 Filename: readFile.c PID: 22763 Filename: rollercoaster.c PID: 22764 Filename: server.c PID: 22765 Filename: simple-cat.c PID: 22766 Filename: simple-ls.c PID: 22767 Filename: sumRecursion.c PID: 22768 Filename: Tree.c PID: 22769 done! gopal@gopal:~/Desktop/chegg$ ./program2 Person.c server.c Filename: Person.c PID: 22814 Filename: server.c PID: 22815 done! Thanks a lot