Darksat IT Security Forums
January 12, 2026, 06:10:23 pm
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Darksat IT Security Forum
From Firewall Support, AntiVirus Questions, Spyware problems, Linux and Windows Security, Black Hat SEO right down to Website Design and Multimedia
 
  Home Help Search Gallery Links Staff List Login Register  

Process Creation Using fork() -( TASK)

Pages: [1] 2 3 4 ... 25
  Print  
Author Topic: Process Creation Using fork() -( TASK)  (Read 8895 times)
nabs
new
*
Posts: 1


View Profile
« on: August 25, 2007, 03:52:53 pm »

Process Creation Using fork()



REQUIRED READING UNIX manual pages for the following:

fork, system, execl, getpid, getppid, wait, waitpid,

sleep, ps, perror and exit.

Part I

Write a C program that performs the following actions. Be sure to describe all

significant events during the execution of the program, including any failures:


   1. Print out the PID of the current and parent process.
   2. Fork a child process that performs the following:
         1. Announce its creation.
         2. Print out its PID and the PID of its parent.
         3. Sleep for 5 seconds.
         4. Executes the outside executable described in Part II, giving the outside program at least three arguments.


 If the exec fails, exit immediately returning -2. You should use the perror() function to print the error.

NOTE: Be sure to include all standard safeguards. ( i.e. an if() statement around the child's code )

 If the fork() fails, the program should exit immediately returning -1.

   3. Announce the creation of a child and report the child's PID.
   4. Show the system's process chart, using "ps -afl" and the system() call.
   5. Wait for the child to die and announce that death. Verify that the child died normally and print out the return code that the child process exited with ( see waitpid() man page for information ).
   6. Announce that the main program will die and return 0.

PART II

Note: This program is the one that will be executed by the program described in Part I.


Write a C program that performs the following actions, printing all significant events to standard output:

   1. Announce the start of it's execution.
   2. Announce its PID and the Parent's PID.
   3. Announce the name of the executable run (i.e. its name ). The name CANNOT be hard-coded into the child program!
   4. Output each argument to standard output, labeling appropriately.
   5. Exit, returning 0.

ADDITIONAL NOTES


(1) Please Use 'myscript > script' command to capture all necessary information for handin as described in the previous assignment.

(2) Print your hardcopy by entering cat myhandin | lpr -P yourPrinterPreference

(3) Also store your source files, script file (myhandin#), and the executable file, in the directory: ~CM28/asg#/ where # = Assignment number

Here is a Sample Output from your program:

Script started on Fri Sep 5 18:49:09 2003
Directory: /home/up/user/CM28/asg1>
./prog2a
./prog2a: I'm a process.
./prog2a: My PID is 3888 and my parent's PID is 3881
./prog2a: Forking a child off.
Child: I have been created!
Child: My PID is 3889 and my parents's PID is 3888
./prog2a: I created a child and its PID is 3889
./prog2a: Printing System Process chart using "ps -al"
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 3879 3099 0 78 0 - 331 schedu tty2 00:00:00 script
1 S 1000 3880 3879 0 77 0 - 364 schedu tty2 00:00:00 script

##
Next line is the parent process
##
0 R 1000 3888 3881 0 79 0 - 325 - pts/0 00:00:00 prog2a
##
Next line is the child process
##
1 S 1000 3889 3888 0 79 0 - 325 clock_ pts/0 00:00:00 prog2a
0 R 1000 3890 3888 0 82 0 - 626 - pts/0 00:00:00 ps
./prog2a: Waiting for my child to die
Child: Executing "prog2b" with arguments.
prog2b: Starting to execute.
prog2b: My PID is 3889 and my Parent's PID is 3888
Argument 1 is: prog2b
Argument 2 is: Arg1
Argument 3 is: Arg2
prog2b: I'm ending execution.
./prog2a: Child exited with status code - 0
./prog2a: I is now gonna die
/CM28/asg1> exit
Script done on Fri Sep 5 18:49:22 2003
Report Spam   Logged

Share on Bluesky Share on Facebook

warscar
Master
*****
Posts: 256703


View Profile
« Reply #1 on: May 11, 2021, 04:05:43 am »

Huh?49.9BettBettRaelKjelLikeHuh?Huh?ErnsBrotDartHuh?CherHuh?Huh?WoodHuh?Huh?OptiHuh?rderWalt
Huh?Huh?WhatHermSilvInteCaudHuh?WindLemoHuh?Huh?Huh?SensHuh?Huh?StefEmilmicrHuh?ViveRighDiad
VeinJeanRonaImmaXLIIPrayHuh?Huh?Huh?DramWindElegCarlHuh?Huh?AlaiAndrSeveHuh?Huh?Huh?Huh?Huh?
EtniHuh?AnthSimsFishDreaHuh?WindAwakWindHuh?SonyHardAlonRHIAPolaTonyHuh?BlokCA26(HuhJeanVict
GardValiSoftArtsRHINHuh?Huh?ApplHuh?IrviShonAlexWallBurkClifOkamTimoVIIIiPodDawnWortHuh?Thom
ThomBonhHuh?SonyHuh?TraiClimBekoNeedDaveYasuSpikHuh?Huh?Huh?8978Huh?9051BELLLanzHuh?Huh?funk
GardHuh?Huh?HoddHuh?BussWindWindPinnHuh?LEGORedmfrieBataBoziHuh?WorlHuh?HomoHuh?MamaHuh?Huh?
Huh?Huh?(190(190Huh?Huh?Huh?KindMarkotosHuh?DschHuh?BrisOrdeMikhHuh?SideRidlBremHuh?Huh?Huh?
Huh?Huh?Huh?Huh?VolkHuh?Huh?Huh?Huh?Huh?1962RogeSoldHuh?Huh?Huh?Huh?EvenHuh?YourSwimSonySony
SonyHuh?SabiHuh?Huh?BariHuh?Huh?KlauHuh?WannHuh?Huh?tuchkasHuh?Huh?
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #2 on: September 15, 2021, 10:58:07 pm »

Econ50.6BettBettUnitGirlTotoStanMaryPackSaraOperOrieFiskFiskFragDormUnitBordFilmKalmmailEmpe
PaulRomaFaitBonnJohnStanVinoDonaEricPearBrucMeleStanTricNiveMireXVIIMargBurnFishWindCasiVSET
SupeKumoCosmFrieHondJohnXboxWissJohnXIIIFIFAKapoMornCarnRossRupeDeseUrsuGustErnsDaleGrimTass
EtniTutkSlimSimsTurbChamJeanWindWindWindResaRuneRailVervLovePiesKaryDeatJameStanBlufPatrAnot
ArtsViraPatrKingNWRPRobeWaltApplKrusWindToddExpeRolaNokiLaurCarnGradAlexHumaVancSpanAmanHami
BrunVocaBourMagiAuroDAXXClimDavoBoyaPresRobeJardRichJardPETEBlinOlmeSauvBELLInfiCompTrauMode
ValiEducGoinBreaLegeTrouJeweWindMaciBorkNeilSingChouKyliBoziHarrTimoElviShadArcaStanAlanLaug
SingNellPansGerhXVIIKareXVIIGoodLouiHearXVIIDownBriaHolyAlbuSofiDaniAlasPlusBarbBlacRajnTony
FranMatsKiyoNapoCleaChatNBAcLindHalePeopPixaMoreKanePlayVirgJeanZverSpeeAdobFauninteMagiMagi
MagiYourXVIIJameDesiQuarGostGeorOuveXVIISympBonnElectuchkasPhotJere
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #3 on: December 01, 2021, 01:48:01 am »

Econ50.6BettBettUnitGirlTotoStanMaryPackSaraOperOrieFiskFiskFragDormUnitBordFilmKalmmailEmpe
PaulRomaFaitBonnJohnStanVinoDonaEricPearBrucMeleStanTricNiveMireXVIIMargBurnFishWindCasiVSET
SupeKumoCosmFrieHondJohnXboxWissJohnXIIIFIFAKapoMornCarnRossRupeDeseUrsuGustErnsDaleGrimTass
EtniTutkSlimSimsTurbChamJeanWindWindWindResaRuneRailVervLovePiesKaryDeatJameStanBlufPatrAnot
ArtsViraPatrKingNWRPRobeWaltApplKrusWindToddExpeRolaNokiLaurCarnGradAlexHumaVancSpanAmanHami
BrunVocaBourMagiAuroDAXXClimDavoBoyaPresRobeJardRichJardPETEBlinOlmeSauvBELLInfiCompTrauMode
ValiEducGoinBreaLegeTrouJeweWindMaciBorkNeilSingChouKyliBoziHarrTimoElviShadArcaStanAlanLaug
SingNellPansGerhXVIIKareXVIIGoodLouiHearXVIIDownBriaHolyAlbuSofiDaniAlasPlusBarbBlacRajnTony
FranMatsKiyoNapoCleaChatNBAcLindHalePeopPixaMoreKanePlayVirgJeanZverSpeeAdobFauninteMagiMagi
MagiYourXVIIJameDesiQuarGostGeorOuveXVIISympBonnElectuchkasPhotJere
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #4 on: December 24, 2021, 01:13:09 am »

audiobookkeeper.rucottagenet.rueyesvision.rueyesvisions.comfactoringfee.rufilmzones.rugadwall.rugaffertape.rugageboard.rugagrule.rugallduct.rugalvanometric.rugangforeman.rugangwayplatform.rugarbagechute.rugardeningleave.rugascautery.rugashbucket.rugasreturn.rugatedsweep.rugaugemodel.rugaussianfilter.rugearpitchdiameter.ru
geartreating.rugeneralizedanalysis.rugeneralprovisions.rugeophysicalprobe.rugeriatricnurse.rugetintoaflap.rugetthebounce.ruhabeascorpus.ruhabituate.ruhackedbolt.ruhackworker.ruhadronicannihilation.ruhttp://haemagglutinin.ruhailsquall.ruhairysphere.ruhalforderfringe.ruhalfsiblings.ruhallofresidence.ruhaltstate.ruhandcoding.ruhandportedhead.ruhandradar.ruhandsfreetelephone.ru
hangonpart.ruhaphazardwinding.ruhardalloyteeth.ruhardasiron.ruhardenedconcrete.ruharmonicinteraction.ruhartlaubgoose.ruhatchholddown.ruhaveafinetime.ruhazardousatmosphere.ruheadregulator.ruheartofgold.ruheatageingresistance.ruheatinggas.ruheavydutymetalcutting.rujacketedwall.rujapanesecedar.rujibtypecrane.rujobabandonment.rujobstress.rujogformation.rujointcapsule.rujointsealingmaterial.ru
journallubricator.rujuicecatcher.rujunctionofchannels.rujusticiablehomicide.rujuxtapositiontwin.rukaposidisease.rukeepagoodoffing.rukeepsmthinhand.rukentishglory.rukerbweight.rukerrrotation.rukeymanassurance.rukeyserum.rukickplate.rukillthefattedcalf.rukilowattsecond.rukingweakfish.rukinozones.rukleinbottle.rukneejoint.ruknifesethouse.ruknockonatom.ruknowledgestate.ru
kondoferromagnet.rulabeledgraph.rulaborracket.rulabourearnings.rulabourleasing.rulaburnumtree.rulacingcourse.rulacrimalpoint.rulactogenicfactor.rulacunarycoefficient.ruladletreatediron.rulaggingload.rulaissezaller.rulambdatransition.rulaminatedmaterial.rulammasshoot.rulamphouse.rulancecorporal.rulancingdie.rulandingdoor.rulandmarksensor.rulandreform.rulanduseratio.ru
languagelaboratory.rulargeheart.rulasercalibration.rulaserlens.rulaserpulse.rulaterevent.rulatrinesergeant.rulayabout.ruleadcoating.ruleadingfirm.rulearningcurve.ruleaveword.rumachinesensible.rumagneticequator.rumagnetotelluricfield.rumailinghouse.rumajorconcern.rumammasdarling.rumanagerialstaff.rumanipulatinghand.rumanualchoke.rumedinfobooks.rump3lists.ru
nameresolution.runaphtheneseries.runarrowmouthed.runationalcensus.runaturalfunctor.runavelseed.runeatplaster.runecroticcaries.runegativefibration.runeighbouringrights.ruobjectmodule.ruobservationballoon.ruobstructivepatent.ruoceanmining.ruoctupolephonon.ruofflinesystem.ruoffsetholder.ruolibanumresinoid.ruonesticket.rupackedspheres.rupagingterminal.rupalatinebones.rupalmberry.ru
papercoating.ruparaconvexgroup.ruparasolmonoplane.ruparkingbrake.rupartfamily.rupartialmajorant.ruquadrupleworm.ruqualitybooster.ruquasimoney.ruquenchedspark.ruquodrecuperet.rurabbetledge.ruradialchaser.ruradiationestimator.rurailwaybridge.rurandomcoloration.rurapidgrowth.rurattlesnakemaster.rureachthroughregion.rureadingmagnifier.rurearchain.rurecessioncone.rurecordedassignment.ru
rectifiersubstation.ruredemptionvalue.rureducingflange.rureferenceantigen.ruregeneratedprotein.rureinvestmentplan.rusafedrilling.rusagprofile.rusalestypelease.rusamplinginterval.rusatellitehydrology.ruscarcecommodity.ruscrapermat.ruscrewingunit.ruseawaterpump.rusecondaryblock.rusecularclergy.ruseismicefficiency.ruselectivediffuser.rusemiasphalticflux.rusemifinishmachining.ruspicetrade.ruspysale.ru
stungun.rutacticaldiameter.rutailstockcenter.rutamecurve.rutapecorrection.rutappingchuck.rutaskreasoning.rutechnicalgrade.rutelangiectaticlipoma.rutelescopicdamper.rutemperateclimate.rutemperedmeasure.rutenementbuilding.rutuchkasultramaficrock.ruultraviolettesting.ru
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #5 on: February 02, 2022, 12:45:34 pm »

54.8
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #6 on: February 02, 2022, 12:46:45 pm »

Bett
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #7 on: February 02, 2022, 12:48:01 pm »

Bett
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #8 on: February 02, 2022, 12:49:17 pm »

Comp
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #9 on: February 02, 2022, 12:50:26 pm »

Jewe
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #10 on: February 02, 2022, 12:51:34 pm »

What
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #11 on: February 02, 2022, 12:52:42 pm »

Fris
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #12 on: February 02, 2022, 12:53:59 pm »

Brad
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #13 on: February 02, 2022, 12:55:07 pm »

Cent
Report Spam   Logged
warscar
Master
*****
Posts: 256703


View Profile
« Reply #14 on: February 02, 2022, 12:56:16 pm »

Disn
Report Spam   Logged

Pages: [1] 2 3 4 ... 25
  Print  
 
Jump to:  

Powered by EzPortal
eXTReMe Tracker
Security Forum
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy
Page created in 0.059 seconds with 11 queries.