libc.info-9 293 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213
  1. This is libc.info, produced by makeinfo version 5.2 from libc.texinfo.
  2. This file documents the GNU C Library.
  3. This is ‘The GNU C Library Reference Manual’, for version 2.25.
  4. Copyright © 1993–2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with the
  8. Invariant Sections being “Free Software Needs Free Documentation” and
  9. “GNU Lesser General Public License”, the Front-Cover texts being “A GNU
  10. Manual”, and with the Back-Cover Texts as in (a) below. A copy of the
  11. license is included in the section entitled "GNU Free Documentation
  12. License".
  13. (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
  14. modify this GNU manual. Buying copies from the FSF supports it in
  15. developing GNU and promoting software freedom.”
  16. INFO-DIR-SECTION Software libraries
  17. START-INFO-DIR-ENTRY
  18. * Libc: (libc). C library.
  19. END-INFO-DIR-ENTRY
  20. INFO-DIR-SECTION GNU C library functions and macros
  21. START-INFO-DIR-ENTRY
  22. * a64l: (libc)Encode Binary Data.
  23. * abort: (libc)Aborting a Program.
  24. * abs: (libc)Absolute Value.
  25. * accept: (libc)Accepting Connections.
  26. * access: (libc)Testing File Access.
  27. * acosf: (libc)Inverse Trig Functions.
  28. * acoshf: (libc)Hyperbolic Functions.
  29. * acosh: (libc)Hyperbolic Functions.
  30. * acoshl: (libc)Hyperbolic Functions.
  31. * acos: (libc)Inverse Trig Functions.
  32. * acosl: (libc)Inverse Trig Functions.
  33. * addmntent: (libc)mtab.
  34. * addseverity: (libc)Adding Severity Classes.
  35. * adjtime: (libc)High-Resolution Calendar.
  36. * adjtimex: (libc)High-Resolution Calendar.
  37. * aio_cancel64: (libc)Cancel AIO Operations.
  38. * aio_cancel: (libc)Cancel AIO Operations.
  39. * aio_error64: (libc)Status of AIO Operations.
  40. * aio_error: (libc)Status of AIO Operations.
  41. * aio_fsync64: (libc)Synchronizing AIO Operations.
  42. * aio_fsync: (libc)Synchronizing AIO Operations.
  43. * aio_init: (libc)Configuration of AIO.
  44. * aio_read64: (libc)Asynchronous Reads/Writes.
  45. * aio_read: (libc)Asynchronous Reads/Writes.
  46. * aio_return64: (libc)Status of AIO Operations.
  47. * aio_return: (libc)Status of AIO Operations.
  48. * aio_suspend64: (libc)Synchronizing AIO Operations.
  49. * aio_suspend: (libc)Synchronizing AIO Operations.
  50. * aio_write64: (libc)Asynchronous Reads/Writes.
  51. * aio_write: (libc)Asynchronous Reads/Writes.
  52. * alarm: (libc)Setting an Alarm.
  53. * aligned_alloc: (libc)Aligned Memory Blocks.
  54. * alloca: (libc)Variable Size Automatic.
  55. * alphasort64: (libc)Scanning Directory Content.
  56. * alphasort: (libc)Scanning Directory Content.
  57. * ALTWERASE: (libc)Local Modes.
  58. * ARG_MAX: (libc)General Limits.
  59. * argp_error: (libc)Argp Helper Functions.
  60. * ARGP_ERR_UNKNOWN: (libc)Argp Parser Functions.
  61. * argp_failure: (libc)Argp Helper Functions.
  62. * argp_help: (libc)Argp Help.
  63. * argp_parse: (libc)Argp.
  64. * argp_state_help: (libc)Argp Helper Functions.
  65. * argp_usage: (libc)Argp Helper Functions.
  66. * argz_add: (libc)Argz Functions.
  67. * argz_add_sep: (libc)Argz Functions.
  68. * argz_append: (libc)Argz Functions.
  69. * argz_count: (libc)Argz Functions.
  70. * argz_create: (libc)Argz Functions.
  71. * argz_create_sep: (libc)Argz Functions.
  72. * argz_delete: (libc)Argz Functions.
  73. * argz_extract: (libc)Argz Functions.
  74. * argz_insert: (libc)Argz Functions.
  75. * argz_next: (libc)Argz Functions.
  76. * argz_replace: (libc)Argz Functions.
  77. * argz_stringify: (libc)Argz Functions.
  78. * asctime: (libc)Formatting Calendar Time.
  79. * asctime_r: (libc)Formatting Calendar Time.
  80. * asinf: (libc)Inverse Trig Functions.
  81. * asinhf: (libc)Hyperbolic Functions.
  82. * asinh: (libc)Hyperbolic Functions.
  83. * asinhl: (libc)Hyperbolic Functions.
  84. * asin: (libc)Inverse Trig Functions.
  85. * asinl: (libc)Inverse Trig Functions.
  86. * asprintf: (libc)Dynamic Output.
  87. * assert: (libc)Consistency Checking.
  88. * assert_perror: (libc)Consistency Checking.
  89. * atan2f: (libc)Inverse Trig Functions.
  90. * atan2: (libc)Inverse Trig Functions.
  91. * atan2l: (libc)Inverse Trig Functions.
  92. * atanf: (libc)Inverse Trig Functions.
  93. * atanhf: (libc)Hyperbolic Functions.
  94. * atanh: (libc)Hyperbolic Functions.
  95. * atanhl: (libc)Hyperbolic Functions.
  96. * atan: (libc)Inverse Trig Functions.
  97. * atanl: (libc)Inverse Trig Functions.
  98. * atexit: (libc)Cleanups on Exit.
  99. * atof: (libc)Parsing of Floats.
  100. * atoi: (libc)Parsing of Integers.
  101. * atol: (libc)Parsing of Integers.
  102. * atoll: (libc)Parsing of Integers.
  103. * backtrace: (libc)Backtraces.
  104. * backtrace_symbols_fd: (libc)Backtraces.
  105. * backtrace_symbols: (libc)Backtraces.
  106. * basename: (libc)Finding Tokens in a String.
  107. * basename: (libc)Finding Tokens in a String.
  108. * BC_BASE_MAX: (libc)Utility Limits.
  109. * BC_DIM_MAX: (libc)Utility Limits.
  110. * bcmp: (libc)String/Array Comparison.
  111. * bcopy: (libc)Copying Strings and Arrays.
  112. * BC_SCALE_MAX: (libc)Utility Limits.
  113. * BC_STRING_MAX: (libc)Utility Limits.
  114. * bind: (libc)Setting Address.
  115. * bind_textdomain_codeset: (libc)Charset conversion in gettext.
  116. * bindtextdomain: (libc)Locating gettext catalog.
  117. * BRKINT: (libc)Input Modes.
  118. * brk: (libc)Resizing the Data Segment.
  119. * bsearch: (libc)Array Search Function.
  120. * btowc: (libc)Converting a Character.
  121. * BUFSIZ: (libc)Controlling Buffering.
  122. * bzero: (libc)Copying Strings and Arrays.
  123. * cabsf: (libc)Absolute Value.
  124. * cabs: (libc)Absolute Value.
  125. * cabsl: (libc)Absolute Value.
  126. * cacosf: (libc)Inverse Trig Functions.
  127. * cacoshf: (libc)Hyperbolic Functions.
  128. * cacosh: (libc)Hyperbolic Functions.
  129. * cacoshl: (libc)Hyperbolic Functions.
  130. * cacos: (libc)Inverse Trig Functions.
  131. * cacosl: (libc)Inverse Trig Functions.
  132. * calloc: (libc)Allocating Cleared Space.
  133. * canonicalize_file_name: (libc)Symbolic Links.
  134. * canonicalizef: (libc)FP Bit Twiddling.
  135. * canonicalize: (libc)FP Bit Twiddling.
  136. * canonicalizel: (libc)FP Bit Twiddling.
  137. * cargf: (libc)Operations on Complex.
  138. * carg: (libc)Operations on Complex.
  139. * cargl: (libc)Operations on Complex.
  140. * casinf: (libc)Inverse Trig Functions.
  141. * casinhf: (libc)Hyperbolic Functions.
  142. * casinh: (libc)Hyperbolic Functions.
  143. * casinhl: (libc)Hyperbolic Functions.
  144. * casin: (libc)Inverse Trig Functions.
  145. * casinl: (libc)Inverse Trig Functions.
  146. * catanf: (libc)Inverse Trig Functions.
  147. * catanhf: (libc)Hyperbolic Functions.
  148. * catanh: (libc)Hyperbolic Functions.
  149. * catanhl: (libc)Hyperbolic Functions.
  150. * catan: (libc)Inverse Trig Functions.
  151. * catanl: (libc)Inverse Trig Functions.
  152. * catclose: (libc)The catgets Functions.
  153. * catgets: (libc)The catgets Functions.
  154. * catopen: (libc)The catgets Functions.
  155. * cbc_crypt: (libc)DES Encryption.
  156. * cbrtf: (libc)Exponents and Logarithms.
  157. * cbrt: (libc)Exponents and Logarithms.
  158. * cbrtl: (libc)Exponents and Logarithms.
  159. * ccosf: (libc)Trig Functions.
  160. * ccoshf: (libc)Hyperbolic Functions.
  161. * ccosh: (libc)Hyperbolic Functions.
  162. * ccoshl: (libc)Hyperbolic Functions.
  163. * ccos: (libc)Trig Functions.
  164. * ccosl: (libc)Trig Functions.
  165. * CCTS_OFLOW: (libc)Control Modes.
  166. * ceilf: (libc)Rounding Functions.
  167. * ceil: (libc)Rounding Functions.
  168. * ceill: (libc)Rounding Functions.
  169. * cexpf: (libc)Exponents and Logarithms.
  170. * cexp: (libc)Exponents and Logarithms.
  171. * cexpl: (libc)Exponents and Logarithms.
  172. * cfgetispeed: (libc)Line Speed.
  173. * cfgetospeed: (libc)Line Speed.
  174. * cfmakeraw: (libc)Noncanonical Input.
  175. * cfree: (libc)Freeing after Malloc.
  176. * cfsetispeed: (libc)Line Speed.
  177. * cfsetospeed: (libc)Line Speed.
  178. * cfsetspeed: (libc)Line Speed.
  179. * chdir: (libc)Working Directory.
  180. * CHILD_MAX: (libc)General Limits.
  181. * chmod: (libc)Setting Permissions.
  182. * chown: (libc)File Owner.
  183. * CIGNORE: (libc)Control Modes.
  184. * cimagf: (libc)Operations on Complex.
  185. * cimag: (libc)Operations on Complex.
  186. * cimagl: (libc)Operations on Complex.
  187. * clearenv: (libc)Environment Access.
  188. * clearerr: (libc)Error Recovery.
  189. * clearerr_unlocked: (libc)Error Recovery.
  190. * CLK_TCK: (libc)Processor Time.
  191. * CLOCAL: (libc)Control Modes.
  192. * clock: (libc)CPU Time.
  193. * CLOCKS_PER_SEC: (libc)CPU Time.
  194. * clog10f: (libc)Exponents and Logarithms.
  195. * clog10: (libc)Exponents and Logarithms.
  196. * clog10l: (libc)Exponents and Logarithms.
  197. * clogf: (libc)Exponents and Logarithms.
  198. * clog: (libc)Exponents and Logarithms.
  199. * clogl: (libc)Exponents and Logarithms.
  200. * closedir: (libc)Reading/Closing Directory.
  201. * close: (libc)Opening and Closing Files.
  202. * closelog: (libc)closelog.
  203. * COLL_WEIGHTS_MAX: (libc)Utility Limits.
  204. * _Complex_I: (libc)Complex Numbers.
  205. * confstr: (libc)String Parameters.
  206. * conjf: (libc)Operations on Complex.
  207. * conj: (libc)Operations on Complex.
  208. * conjl: (libc)Operations on Complex.
  209. * connect: (libc)Connecting.
  210. * copysignf: (libc)FP Bit Twiddling.
  211. * copysign: (libc)FP Bit Twiddling.
  212. * copysignl: (libc)FP Bit Twiddling.
  213. * cosf: (libc)Trig Functions.
  214. * coshf: (libc)Hyperbolic Functions.
  215. * cosh: (libc)Hyperbolic Functions.
  216. * coshl: (libc)Hyperbolic Functions.
  217. * cos: (libc)Trig Functions.
  218. * cosl: (libc)Trig Functions.
  219. * cpowf: (libc)Exponents and Logarithms.
  220. * cpow: (libc)Exponents and Logarithms.
  221. * cpowl: (libc)Exponents and Logarithms.
  222. * cprojf: (libc)Operations on Complex.
  223. * cproj: (libc)Operations on Complex.
  224. * cprojl: (libc)Operations on Complex.
  225. * CPU_CLR: (libc)CPU Affinity.
  226. * CPU_ISSET: (libc)CPU Affinity.
  227. * CPU_SET: (libc)CPU Affinity.
  228. * CPU_SETSIZE: (libc)CPU Affinity.
  229. * CPU_ZERO: (libc)CPU Affinity.
  230. * CREAD: (libc)Control Modes.
  231. * crealf: (libc)Operations on Complex.
  232. * creal: (libc)Operations on Complex.
  233. * creall: (libc)Operations on Complex.
  234. * creat64: (libc)Opening and Closing Files.
  235. * creat: (libc)Opening and Closing Files.
  236. * CRTS_IFLOW: (libc)Control Modes.
  237. * crypt: (libc)crypt.
  238. * crypt_r: (libc)crypt.
  239. * CS5: (libc)Control Modes.
  240. * CS6: (libc)Control Modes.
  241. * CS7: (libc)Control Modes.
  242. * CS8: (libc)Control Modes.
  243. * csinf: (libc)Trig Functions.
  244. * csinhf: (libc)Hyperbolic Functions.
  245. * csinh: (libc)Hyperbolic Functions.
  246. * csinhl: (libc)Hyperbolic Functions.
  247. * csin: (libc)Trig Functions.
  248. * csinl: (libc)Trig Functions.
  249. * CSIZE: (libc)Control Modes.
  250. * csqrtf: (libc)Exponents and Logarithms.
  251. * csqrt: (libc)Exponents and Logarithms.
  252. * csqrtl: (libc)Exponents and Logarithms.
  253. * CSTOPB: (libc)Control Modes.
  254. * ctanf: (libc)Trig Functions.
  255. * ctanhf: (libc)Hyperbolic Functions.
  256. * ctanh: (libc)Hyperbolic Functions.
  257. * ctanhl: (libc)Hyperbolic Functions.
  258. * ctan: (libc)Trig Functions.
  259. * ctanl: (libc)Trig Functions.
  260. * ctermid: (libc)Identifying the Terminal.
  261. * ctime: (libc)Formatting Calendar Time.
  262. * ctime_r: (libc)Formatting Calendar Time.
  263. * cuserid: (libc)Who Logged In.
  264. * dcgettext: (libc)Translation with gettext.
  265. * dcngettext: (libc)Advanced gettext functions.
  266. * DES_FAILED: (libc)DES Encryption.
  267. * des_setparity: (libc)DES Encryption.
  268. * dgettext: (libc)Translation with gettext.
  269. * difftime: (libc)Elapsed Time.
  270. * dirfd: (libc)Opening a Directory.
  271. * dirname: (libc)Finding Tokens in a String.
  272. * div: (libc)Integer Division.
  273. * dngettext: (libc)Advanced gettext functions.
  274. * drand48: (libc)SVID Random.
  275. * drand48_r: (libc)SVID Random.
  276. * dremf: (libc)Remainder Functions.
  277. * drem: (libc)Remainder Functions.
  278. * dreml: (libc)Remainder Functions.
  279. * DTTOIF: (libc)Directory Entries.
  280. * dup2: (libc)Duplicating Descriptors.
  281. * dup: (libc)Duplicating Descriptors.
  282. * E2BIG: (libc)Error Codes.
  283. * EACCES: (libc)Error Codes.
  284. * EADDRINUSE: (libc)Error Codes.
  285. * EADDRNOTAVAIL: (libc)Error Codes.
  286. * EADV: (libc)Error Codes.
  287. * EAFNOSUPPORT: (libc)Error Codes.
  288. * EAGAIN: (libc)Error Codes.
  289. * EALREADY: (libc)Error Codes.
  290. * EAUTH: (libc)Error Codes.
  291. * EBACKGROUND: (libc)Error Codes.
  292. * EBADE: (libc)Error Codes.
  293. * EBADFD: (libc)Error Codes.
  294. * EBADF: (libc)Error Codes.
  295. * EBADMSG: (libc)Error Codes.
  296. * EBADR: (libc)Error Codes.
  297. * EBADRPC: (libc)Error Codes.
  298. * EBADRQC: (libc)Error Codes.
  299. * EBADSLT: (libc)Error Codes.
  300. * EBFONT: (libc)Error Codes.
  301. * EBUSY: (libc)Error Codes.
  302. * ECANCELED: (libc)Error Codes.
  303. * ecb_crypt: (libc)DES Encryption.
  304. * ECHILD: (libc)Error Codes.
  305. * ECHOCTL: (libc)Local Modes.
  306. * ECHOE: (libc)Local Modes.
  307. * ECHOKE: (libc)Local Modes.
  308. * ECHOK: (libc)Local Modes.
  309. * ECHO: (libc)Local Modes.
  310. * ECHONL: (libc)Local Modes.
  311. * ECHOPRT: (libc)Local Modes.
  312. * ECHRNG: (libc)Error Codes.
  313. * ECOMM: (libc)Error Codes.
  314. * ECONNABORTED: (libc)Error Codes.
  315. * ECONNREFUSED: (libc)Error Codes.
  316. * ECONNRESET: (libc)Error Codes.
  317. * ecvt: (libc)System V Number Conversion.
  318. * ecvt_r: (libc)System V Number Conversion.
  319. * EDEADLK: (libc)Error Codes.
  320. * EDEADLOCK: (libc)Error Codes.
  321. * EDESTADDRREQ: (libc)Error Codes.
  322. * EDIED: (libc)Error Codes.
  323. * ED: (libc)Error Codes.
  324. * EDOM: (libc)Error Codes.
  325. * EDOTDOT: (libc)Error Codes.
  326. * EDQUOT: (libc)Error Codes.
  327. * EEXIST: (libc)Error Codes.
  328. * EFAULT: (libc)Error Codes.
  329. * EFBIG: (libc)Error Codes.
  330. * EFTYPE: (libc)Error Codes.
  331. * EGRATUITOUS: (libc)Error Codes.
  332. * EGREGIOUS: (libc)Error Codes.
  333. * EHOSTDOWN: (libc)Error Codes.
  334. * EHOSTUNREACH: (libc)Error Codes.
  335. * EHWPOISON: (libc)Error Codes.
  336. * EIDRM: (libc)Error Codes.
  337. * EIEIO: (libc)Error Codes.
  338. * EILSEQ: (libc)Error Codes.
  339. * EINPROGRESS: (libc)Error Codes.
  340. * EINTR: (libc)Error Codes.
  341. * EINVAL: (libc)Error Codes.
  342. * EIO: (libc)Error Codes.
  343. * EISCONN: (libc)Error Codes.
  344. * EISDIR: (libc)Error Codes.
  345. * EISNAM: (libc)Error Codes.
  346. * EKEYEXPIRED: (libc)Error Codes.
  347. * EKEYREJECTED: (libc)Error Codes.
  348. * EKEYREVOKED: (libc)Error Codes.
  349. * EL2HLT: (libc)Error Codes.
  350. * EL2NSYNC: (libc)Error Codes.
  351. * EL3HLT: (libc)Error Codes.
  352. * EL3RST: (libc)Error Codes.
  353. * ELIBACC: (libc)Error Codes.
  354. * ELIBBAD: (libc)Error Codes.
  355. * ELIBEXEC: (libc)Error Codes.
  356. * ELIBMAX: (libc)Error Codes.
  357. * ELIBSCN: (libc)Error Codes.
  358. * ELNRNG: (libc)Error Codes.
  359. * ELOOP: (libc)Error Codes.
  360. * EMEDIUMTYPE: (libc)Error Codes.
  361. * EMFILE: (libc)Error Codes.
  362. * EMLINK: (libc)Error Codes.
  363. * EMSGSIZE: (libc)Error Codes.
  364. * EMULTIHOP: (libc)Error Codes.
  365. * ENAMETOOLONG: (libc)Error Codes.
  366. * ENAVAIL: (libc)Error Codes.
  367. * encrypt: (libc)DES Encryption.
  368. * encrypt_r: (libc)DES Encryption.
  369. * endfsent: (libc)fstab.
  370. * endgrent: (libc)Scanning All Groups.
  371. * endhostent: (libc)Host Names.
  372. * endmntent: (libc)mtab.
  373. * endnetent: (libc)Networks Database.
  374. * endnetgrent: (libc)Lookup Netgroup.
  375. * endprotoent: (libc)Protocols Database.
  376. * endpwent: (libc)Scanning All Users.
  377. * endservent: (libc)Services Database.
  378. * endutent: (libc)Manipulating the Database.
  379. * endutxent: (libc)XPG Functions.
  380. * ENEEDAUTH: (libc)Error Codes.
  381. * ENETDOWN: (libc)Error Codes.
  382. * ENETRESET: (libc)Error Codes.
  383. * ENETUNREACH: (libc)Error Codes.
  384. * ENFILE: (libc)Error Codes.
  385. * ENOANO: (libc)Error Codes.
  386. * ENOBUFS: (libc)Error Codes.
  387. * ENOCSI: (libc)Error Codes.
  388. * ENODATA: (libc)Error Codes.
  389. * ENODEV: (libc)Error Codes.
  390. * ENOENT: (libc)Error Codes.
  391. * ENOEXEC: (libc)Error Codes.
  392. * ENOKEY: (libc)Error Codes.
  393. * ENOLCK: (libc)Error Codes.
  394. * ENOLINK: (libc)Error Codes.
  395. * ENOMEDIUM: (libc)Error Codes.
  396. * ENOMEM: (libc)Error Codes.
  397. * ENOMSG: (libc)Error Codes.
  398. * ENONET: (libc)Error Codes.
  399. * ENOPKG: (libc)Error Codes.
  400. * ENOPROTOOPT: (libc)Error Codes.
  401. * ENOSPC: (libc)Error Codes.
  402. * ENOSR: (libc)Error Codes.
  403. * ENOSTR: (libc)Error Codes.
  404. * ENOSYS: (libc)Error Codes.
  405. * ENOTBLK: (libc)Error Codes.
  406. * ENOTCONN: (libc)Error Codes.
  407. * ENOTDIR: (libc)Error Codes.
  408. * ENOTEMPTY: (libc)Error Codes.
  409. * ENOTNAM: (libc)Error Codes.
  410. * ENOTRECOVERABLE: (libc)Error Codes.
  411. * ENOTSOCK: (libc)Error Codes.
  412. * ENOTSUP: (libc)Error Codes.
  413. * ENOTTY: (libc)Error Codes.
  414. * ENOTUNIQ: (libc)Error Codes.
  415. * envz_add: (libc)Envz Functions.
  416. * envz_entry: (libc)Envz Functions.
  417. * envz_get: (libc)Envz Functions.
  418. * envz_merge: (libc)Envz Functions.
  419. * envz_remove: (libc)Envz Functions.
  420. * envz_strip: (libc)Envz Functions.
  421. * ENXIO: (libc)Error Codes.
  422. * EOF: (libc)EOF and Errors.
  423. * EOPNOTSUPP: (libc)Error Codes.
  424. * EOVERFLOW: (libc)Error Codes.
  425. * EOWNERDEAD: (libc)Error Codes.
  426. * EPERM: (libc)Error Codes.
  427. * EPFNOSUPPORT: (libc)Error Codes.
  428. * EPIPE: (libc)Error Codes.
  429. * EPROCLIM: (libc)Error Codes.
  430. * EPROCUNAVAIL: (libc)Error Codes.
  431. * EPROGMISMATCH: (libc)Error Codes.
  432. * EPROGUNAVAIL: (libc)Error Codes.
  433. * EPROTO: (libc)Error Codes.
  434. * EPROTONOSUPPORT: (libc)Error Codes.
  435. * EPROTOTYPE: (libc)Error Codes.
  436. * EQUIV_CLASS_MAX: (libc)Utility Limits.
  437. * erand48: (libc)SVID Random.
  438. * erand48_r: (libc)SVID Random.
  439. * ERANGE: (libc)Error Codes.
  440. * EREMCHG: (libc)Error Codes.
  441. * EREMOTEIO: (libc)Error Codes.
  442. * EREMOTE: (libc)Error Codes.
  443. * ERESTART: (libc)Error Codes.
  444. * erfcf: (libc)Special Functions.
  445. * erfc: (libc)Special Functions.
  446. * erfcl: (libc)Special Functions.
  447. * erff: (libc)Special Functions.
  448. * ERFKILL: (libc)Error Codes.
  449. * erf: (libc)Special Functions.
  450. * erfl: (libc)Special Functions.
  451. * EROFS: (libc)Error Codes.
  452. * ERPCMISMATCH: (libc)Error Codes.
  453. * err: (libc)Error Messages.
  454. * errno: (libc)Checking for Errors.
  455. * error_at_line: (libc)Error Messages.
  456. * error: (libc)Error Messages.
  457. * errx: (libc)Error Messages.
  458. * ESHUTDOWN: (libc)Error Codes.
  459. * ESOCKTNOSUPPORT: (libc)Error Codes.
  460. * ESPIPE: (libc)Error Codes.
  461. * ESRCH: (libc)Error Codes.
  462. * ESRMNT: (libc)Error Codes.
  463. * ESTALE: (libc)Error Codes.
  464. * ESTRPIPE: (libc)Error Codes.
  465. * ETIMEDOUT: (libc)Error Codes.
  466. * ETIME: (libc)Error Codes.
  467. * ETOOMANYREFS: (libc)Error Codes.
  468. * ETXTBSY: (libc)Error Codes.
  469. * EUCLEAN: (libc)Error Codes.
  470. * EUNATCH: (libc)Error Codes.
  471. * EUSERS: (libc)Error Codes.
  472. * EWOULDBLOCK: (libc)Error Codes.
  473. * EXDEV: (libc)Error Codes.
  474. * execle: (libc)Executing a File.
  475. * execl: (libc)Executing a File.
  476. * execlp: (libc)Executing a File.
  477. * execve: (libc)Executing a File.
  478. * execv: (libc)Executing a File.
  479. * execvp: (libc)Executing a File.
  480. * EXFULL: (libc)Error Codes.
  481. * EXIT_FAILURE: (libc)Exit Status.
  482. * exit: (libc)Normal Termination.
  483. * _exit: (libc)Termination Internals.
  484. * _Exit: (libc)Termination Internals.
  485. * EXIT_SUCCESS: (libc)Exit Status.
  486. * exp10f: (libc)Exponents and Logarithms.
  487. * exp10: (libc)Exponents and Logarithms.
  488. * exp10l: (libc)Exponents and Logarithms.
  489. * exp2f: (libc)Exponents and Logarithms.
  490. * exp2: (libc)Exponents and Logarithms.
  491. * exp2l: (libc)Exponents and Logarithms.
  492. * expf: (libc)Exponents and Logarithms.
  493. * exp: (libc)Exponents and Logarithms.
  494. * explicit_bzero: (libc)Erasing Sensitive Data.
  495. * expl: (libc)Exponents and Logarithms.
  496. * expm1f: (libc)Exponents and Logarithms.
  497. * expm1: (libc)Exponents and Logarithms.
  498. * expm1l: (libc)Exponents and Logarithms.
  499. * EXPR_NEST_MAX: (libc)Utility Limits.
  500. * fabsf: (libc)Absolute Value.
  501. * fabs: (libc)Absolute Value.
  502. * fabsl: (libc)Absolute Value.
  503. * __fbufsize: (libc)Controlling Buffering.
  504. * fchdir: (libc)Working Directory.
  505. * fchmod: (libc)Setting Permissions.
  506. * fchown: (libc)File Owner.
  507. * fcloseall: (libc)Closing Streams.
  508. * fclose: (libc)Closing Streams.
  509. * fcntl: (libc)Control Operations.
  510. * fcvt: (libc)System V Number Conversion.
  511. * fcvt_r: (libc)System V Number Conversion.
  512. * fdatasync: (libc)Synchronizing I/O.
  513. * FD_CLOEXEC: (libc)Descriptor Flags.
  514. * FD_CLR: (libc)Waiting for I/O.
  515. * fdimf: (libc)Misc FP Arithmetic.
  516. * fdim: (libc)Misc FP Arithmetic.
  517. * fdiml: (libc)Misc FP Arithmetic.
  518. * FD_ISSET: (libc)Waiting for I/O.
  519. * fdopendir: (libc)Opening a Directory.
  520. * fdopen: (libc)Descriptors and Streams.
  521. * FD_SET: (libc)Waiting for I/O.
  522. * FD_SETSIZE: (libc)Waiting for I/O.
  523. * F_DUPFD: (libc)Duplicating Descriptors.
  524. * FD_ZERO: (libc)Waiting for I/O.
  525. * feclearexcept: (libc)Status bit operations.
  526. * fedisableexcept: (libc)Control Functions.
  527. * feenableexcept: (libc)Control Functions.
  528. * fegetenv: (libc)Control Functions.
  529. * fegetexceptflag: (libc)Status bit operations.
  530. * fegetexcept: (libc)Control Functions.
  531. * fegetmode: (libc)Control Functions.
  532. * fegetround: (libc)Rounding.
  533. * feholdexcept: (libc)Control Functions.
  534. * feof: (libc)EOF and Errors.
  535. * feof_unlocked: (libc)EOF and Errors.
  536. * feraiseexcept: (libc)Status bit operations.
  537. * ferror: (libc)EOF and Errors.
  538. * ferror_unlocked: (libc)EOF and Errors.
  539. * fesetenv: (libc)Control Functions.
  540. * fesetexceptflag: (libc)Status bit operations.
  541. * fesetexcept: (libc)Status bit operations.
  542. * fesetmode: (libc)Control Functions.
  543. * fesetround: (libc)Rounding.
  544. * FE_SNANS_ALWAYS_SIGNAL: (libc)Infinity and NaN.
  545. * fetestexceptflag: (libc)Status bit operations.
  546. * fetestexcept: (libc)Status bit operations.
  547. * feupdateenv: (libc)Control Functions.
  548. * fflush: (libc)Flushing Buffers.
  549. * fflush_unlocked: (libc)Flushing Buffers.
  550. * fgetc: (libc)Character Input.
  551. * fgetc_unlocked: (libc)Character Input.
  552. * F_GETFD: (libc)Descriptor Flags.
  553. * F_GETFL: (libc)Getting File Status Flags.
  554. * fgetgrent: (libc)Scanning All Groups.
  555. * fgetgrent_r: (libc)Scanning All Groups.
  556. * F_GETLK: (libc)File Locks.
  557. * F_GETOWN: (libc)Interrupt Input.
  558. * fgetpos64: (libc)Portable Positioning.
  559. * fgetpos: (libc)Portable Positioning.
  560. * fgetpwent: (libc)Scanning All Users.
  561. * fgetpwent_r: (libc)Scanning All Users.
  562. * fgets: (libc)Line Input.
  563. * fgets_unlocked: (libc)Line Input.
  564. * fgetwc: (libc)Character Input.
  565. * fgetwc_unlocked: (libc)Character Input.
  566. * fgetws: (libc)Line Input.
  567. * fgetws_unlocked: (libc)Line Input.
  568. * FILENAME_MAX: (libc)Limits for Files.
  569. * fileno: (libc)Descriptors and Streams.
  570. * fileno_unlocked: (libc)Descriptors and Streams.
  571. * finitef: (libc)Floating Point Classes.
  572. * finite: (libc)Floating Point Classes.
  573. * finitel: (libc)Floating Point Classes.
  574. * __flbf: (libc)Controlling Buffering.
  575. * flockfile: (libc)Streams and Threads.
  576. * floorf: (libc)Rounding Functions.
  577. * floor: (libc)Rounding Functions.
  578. * floorl: (libc)Rounding Functions.
  579. * _flushlbf: (libc)Flushing Buffers.
  580. * FLUSHO: (libc)Local Modes.
  581. * fmaf: (libc)Misc FP Arithmetic.
  582. * fma: (libc)Misc FP Arithmetic.
  583. * fmal: (libc)Misc FP Arithmetic.
  584. * fmaxf: (libc)Misc FP Arithmetic.
  585. * fmax: (libc)Misc FP Arithmetic.
  586. * fmaxl: (libc)Misc FP Arithmetic.
  587. * fmaxmagf: (libc)Misc FP Arithmetic.
  588. * fmaxmag: (libc)Misc FP Arithmetic.
  589. * fmaxmagl: (libc)Misc FP Arithmetic.
  590. * fmemopen: (libc)String Streams.
  591. * fminf: (libc)Misc FP Arithmetic.
  592. * fmin: (libc)Misc FP Arithmetic.
  593. * fminl: (libc)Misc FP Arithmetic.
  594. * fminmagf: (libc)Misc FP Arithmetic.
  595. * fminmag: (libc)Misc FP Arithmetic.
  596. * fminmagl: (libc)Misc FP Arithmetic.
  597. * fmodf: (libc)Remainder Functions.
  598. * fmod: (libc)Remainder Functions.
  599. * fmodl: (libc)Remainder Functions.
  600. * fmtmsg: (libc)Printing Formatted Messages.
  601. * fnmatch: (libc)Wildcard Matching.
  602. * F_OFD_GETLK: (libc)Open File Description Locks.
  603. * F_OFD_SETLK: (libc)Open File Description Locks.
  604. * F_OFD_SETLKW: (libc)Open File Description Locks.
  605. * F_OK: (libc)Testing File Access.
  606. * fopen64: (libc)Opening Streams.
  607. * fopencookie: (libc)Streams and Cookies.
  608. * fopen: (libc)Opening Streams.
  609. * FOPEN_MAX: (libc)Opening Streams.
  610. * fork: (libc)Creating a Process.
  611. * forkpty: (libc)Pseudo-Terminal Pairs.
  612. * fpathconf: (libc)Pathconf.
  613. * fpclassify: (libc)Floating Point Classes.
  614. * __fpending: (libc)Controlling Buffering.
  615. * FP_ILOGB0: (libc)Exponents and Logarithms.
  616. * FP_ILOGBNAN: (libc)Exponents and Logarithms.
  617. * FP_LLOGB0: (libc)Exponents and Logarithms.
  618. * FP_LLOGBNAN: (libc)Exponents and Logarithms.
  619. * fprintf: (libc)Formatted Output Functions.
  620. * __fpurge: (libc)Flushing Buffers.
  621. * fputc: (libc)Simple Output.
  622. * fputc_unlocked: (libc)Simple Output.
  623. * fputs: (libc)Simple Output.
  624. * fputs_unlocked: (libc)Simple Output.
  625. * fputwc: (libc)Simple Output.
  626. * fputwc_unlocked: (libc)Simple Output.
  627. * fputws: (libc)Simple Output.
  628. * fputws_unlocked: (libc)Simple Output.
  629. * __freadable: (libc)Opening Streams.
  630. * __freading: (libc)Opening Streams.
  631. * fread: (libc)Block Input/Output.
  632. * fread_unlocked: (libc)Block Input/Output.
  633. * free: (libc)Freeing after Malloc.
  634. * freopen64: (libc)Opening Streams.
  635. * freopen: (libc)Opening Streams.
  636. * frexpf: (libc)Normalization Functions.
  637. * frexp: (libc)Normalization Functions.
  638. * frexpl: (libc)Normalization Functions.
  639. * fromfpf: (libc)Rounding Functions.
  640. * fromfp: (libc)Rounding Functions.
  641. * fromfpl: (libc)Rounding Functions.
  642. * fromfpxf: (libc)Rounding Functions.
  643. * fromfpx: (libc)Rounding Functions.
  644. * fromfpxl: (libc)Rounding Functions.
  645. * fscanf: (libc)Formatted Input Functions.
  646. * fseek: (libc)File Positioning.
  647. * fseeko64: (libc)File Positioning.
  648. * fseeko: (libc)File Positioning.
  649. * F_SETFD: (libc)Descriptor Flags.
  650. * F_SETFL: (libc)Getting File Status Flags.
  651. * F_SETLK: (libc)File Locks.
  652. * F_SETLKW: (libc)File Locks.
  653. * __fsetlocking: (libc)Streams and Threads.
  654. * F_SETOWN: (libc)Interrupt Input.
  655. * fsetpos64: (libc)Portable Positioning.
  656. * fsetpos: (libc)Portable Positioning.
  657. * fstat64: (libc)Reading Attributes.
  658. * fstat: (libc)Reading Attributes.
  659. * fsync: (libc)Synchronizing I/O.
  660. * ftell: (libc)File Positioning.
  661. * ftello64: (libc)File Positioning.
  662. * ftello: (libc)File Positioning.
  663. * ftruncate64: (libc)File Size.
  664. * ftruncate: (libc)File Size.
  665. * ftrylockfile: (libc)Streams and Threads.
  666. * ftw64: (libc)Working with Directory Trees.
  667. * ftw: (libc)Working with Directory Trees.
  668. * funlockfile: (libc)Streams and Threads.
  669. * futimes: (libc)File Times.
  670. * fwide: (libc)Streams and I18N.
  671. * fwprintf: (libc)Formatted Output Functions.
  672. * __fwritable: (libc)Opening Streams.
  673. * fwrite: (libc)Block Input/Output.
  674. * fwrite_unlocked: (libc)Block Input/Output.
  675. * __fwriting: (libc)Opening Streams.
  676. * fwscanf: (libc)Formatted Input Functions.
  677. * gammaf: (libc)Special Functions.
  678. * gamma: (libc)Special Functions.
  679. * gammal: (libc)Special Functions.
  680. * __gconv_end_fct: (libc)glibc iconv Implementation.
  681. * __gconv_fct: (libc)glibc iconv Implementation.
  682. * __gconv_init_fct: (libc)glibc iconv Implementation.
  683. * gcvt: (libc)System V Number Conversion.
  684. * getauxval: (libc)Auxiliary Vector.
  685. * get_avphys_pages: (libc)Query Memory Parameters.
  686. * getchar: (libc)Character Input.
  687. * getchar_unlocked: (libc)Character Input.
  688. * getc: (libc)Character Input.
  689. * getcontext: (libc)System V contexts.
  690. * getc_unlocked: (libc)Character Input.
  691. * get_current_dir_name: (libc)Working Directory.
  692. * getcwd: (libc)Working Directory.
  693. * getdate: (libc)General Time String Parsing.
  694. * getdate_r: (libc)General Time String Parsing.
  695. * getdelim: (libc)Line Input.
  696. * getdomainnname: (libc)Host Identification.
  697. * getegid: (libc)Reading Persona.
  698. * getentropy: (libc)Unpredictable Bytes.
  699. * getenv: (libc)Environment Access.
  700. * geteuid: (libc)Reading Persona.
  701. * getfsent: (libc)fstab.
  702. * getfsfile: (libc)fstab.
  703. * getfsspec: (libc)fstab.
  704. * getgid: (libc)Reading Persona.
  705. * getgrent: (libc)Scanning All Groups.
  706. * getgrent_r: (libc)Scanning All Groups.
  707. * getgrgid: (libc)Lookup Group.
  708. * getgrgid_r: (libc)Lookup Group.
  709. * getgrnam: (libc)Lookup Group.
  710. * getgrnam_r: (libc)Lookup Group.
  711. * getgrouplist: (libc)Setting Groups.
  712. * getgroups: (libc)Reading Persona.
  713. * gethostbyaddr: (libc)Host Names.
  714. * gethostbyaddr_r: (libc)Host Names.
  715. * gethostbyname2: (libc)Host Names.
  716. * gethostbyname2_r: (libc)Host Names.
  717. * gethostbyname: (libc)Host Names.
  718. * gethostbyname_r: (libc)Host Names.
  719. * gethostent: (libc)Host Names.
  720. * gethostid: (libc)Host Identification.
  721. * gethostname: (libc)Host Identification.
  722. * getitimer: (libc)Setting an Alarm.
  723. * getline: (libc)Line Input.
  724. * getloadavg: (libc)Processor Resources.
  725. * getlogin: (libc)Who Logged In.
  726. * getmntent: (libc)mtab.
  727. * getmntent_r: (libc)mtab.
  728. * getnetbyaddr: (libc)Networks Database.
  729. * getnetbyname: (libc)Networks Database.
  730. * getnetent: (libc)Networks Database.
  731. * getnetgrent: (libc)Lookup Netgroup.
  732. * getnetgrent_r: (libc)Lookup Netgroup.
  733. * get_nprocs_conf: (libc)Processor Resources.
  734. * get_nprocs: (libc)Processor Resources.
  735. * getopt: (libc)Using Getopt.
  736. * getopt_long: (libc)Getopt Long Options.
  737. * getopt_long_only: (libc)Getopt Long Options.
  738. * getpagesize: (libc)Query Memory Parameters.
  739. * getpass: (libc)getpass.
  740. * getpayloadf: (libc)FP Bit Twiddling.
  741. * getpayload: (libc)FP Bit Twiddling.
  742. * getpayloadl: (libc)FP Bit Twiddling.
  743. * getpeername: (libc)Who is Connected.
  744. * getpgid: (libc)Process Group Functions.
  745. * getpgrp: (libc)Process Group Functions.
  746. * get_phys_pages: (libc)Query Memory Parameters.
  747. * getpid: (libc)Process Identification.
  748. * getppid: (libc)Process Identification.
  749. * getpriority: (libc)Traditional Scheduling Functions.
  750. * getprotobyname: (libc)Protocols Database.
  751. * getprotobynumber: (libc)Protocols Database.
  752. * getprotoent: (libc)Protocols Database.
  753. * getpt: (libc)Allocation.
  754. * getpwent: (libc)Scanning All Users.
  755. * getpwent_r: (libc)Scanning All Users.
  756. * getpwnam: (libc)Lookup User.
  757. * getpwnam_r: (libc)Lookup User.
  758. * getpwuid: (libc)Lookup User.
  759. * getpwuid_r: (libc)Lookup User.
  760. * getrandom: (libc)Unpredictable Bytes.
  761. * getrlimit64: (libc)Limits on Resources.
  762. * getrlimit: (libc)Limits on Resources.
  763. * getrusage: (libc)Resource Usage.
  764. * getservbyname: (libc)Services Database.
  765. * getservbyport: (libc)Services Database.
  766. * getservent: (libc)Services Database.
  767. * getsid: (libc)Process Group Functions.
  768. * gets: (libc)Line Input.
  769. * getsockname: (libc)Reading Address.
  770. * getsockopt: (libc)Socket Option Functions.
  771. * getsubopt: (libc)Suboptions.
  772. * gettext: (libc)Translation with gettext.
  773. * gettimeofday: (libc)High-Resolution Calendar.
  774. * getuid: (libc)Reading Persona.
  775. * getumask: (libc)Setting Permissions.
  776. * getutent: (libc)Manipulating the Database.
  777. * getutent_r: (libc)Manipulating the Database.
  778. * getutid: (libc)Manipulating the Database.
  779. * getutid_r: (libc)Manipulating the Database.
  780. * getutline: (libc)Manipulating the Database.
  781. * getutline_r: (libc)Manipulating the Database.
  782. * getutmp: (libc)XPG Functions.
  783. * getutmpx: (libc)XPG Functions.
  784. * getutxent: (libc)XPG Functions.
  785. * getutxid: (libc)XPG Functions.
  786. * getutxline: (libc)XPG Functions.
  787. * getwchar: (libc)Character Input.
  788. * getwchar_unlocked: (libc)Character Input.
  789. * getwc: (libc)Character Input.
  790. * getwc_unlocked: (libc)Character Input.
  791. * getwd: (libc)Working Directory.
  792. * getw: (libc)Character Input.
  793. * glob64: (libc)Calling Glob.
  794. * globfree64: (libc)More Flags for Globbing.
  795. * globfree: (libc)More Flags for Globbing.
  796. * glob: (libc)Calling Glob.
  797. * gmtime: (libc)Broken-down Time.
  798. * gmtime_r: (libc)Broken-down Time.
  799. * grantpt: (libc)Allocation.
  800. * gsignal: (libc)Signaling Yourself.
  801. * gtty: (libc)BSD Terminal Modes.
  802. * hasmntopt: (libc)mtab.
  803. * hcreate: (libc)Hash Search Function.
  804. * hcreate_r: (libc)Hash Search Function.
  805. * hdestroy: (libc)Hash Search Function.
  806. * hdestroy_r: (libc)Hash Search Function.
  807. * hsearch: (libc)Hash Search Function.
  808. * hsearch_r: (libc)Hash Search Function.
  809. * htonl: (libc)Byte Order.
  810. * htons: (libc)Byte Order.
  811. * HUGE_VALF: (libc)Math Error Reporting.
  812. * HUGE_VAL: (libc)Math Error Reporting.
  813. * HUGE_VALL: (libc)Math Error Reporting.
  814. * HUPCL: (libc)Control Modes.
  815. * hypotf: (libc)Exponents and Logarithms.
  816. * hypot: (libc)Exponents and Logarithms.
  817. * hypotl: (libc)Exponents and Logarithms.
  818. * ICANON: (libc)Local Modes.
  819. * iconv_close: (libc)Generic Conversion Interface.
  820. * iconv: (libc)Generic Conversion Interface.
  821. * iconv_open: (libc)Generic Conversion Interface.
  822. * ICRNL: (libc)Input Modes.
  823. * IEXTEN: (libc)Local Modes.
  824. * if_freenameindex: (libc)Interface Naming.
  825. * if_indextoname: (libc)Interface Naming.
  826. * if_nameindex: (libc)Interface Naming.
  827. * if_nametoindex: (libc)Interface Naming.
  828. * IFNAMSIZ: (libc)Interface Naming.
  829. * IFTODT: (libc)Directory Entries.
  830. * IGNBRK: (libc)Input Modes.
  831. * IGNCR: (libc)Input Modes.
  832. * IGNPAR: (libc)Input Modes.
  833. * I: (libc)Complex Numbers.
  834. * ilogbf: (libc)Exponents and Logarithms.
  835. * ilogb: (libc)Exponents and Logarithms.
  836. * ilogbl: (libc)Exponents and Logarithms.
  837. * _Imaginary_I: (libc)Complex Numbers.
  838. * imaxabs: (libc)Absolute Value.
  839. * IMAXBEL: (libc)Input Modes.
  840. * imaxdiv: (libc)Integer Division.
  841. * in6addr_any: (libc)Host Address Data Type.
  842. * in6addr_loopback: (libc)Host Address Data Type.
  843. * INADDR_ANY: (libc)Host Address Data Type.
  844. * INADDR_BROADCAST: (libc)Host Address Data Type.
  845. * INADDR_LOOPBACK: (libc)Host Address Data Type.
  846. * INADDR_NONE: (libc)Host Address Data Type.
  847. * index: (libc)Search Functions.
  848. * inet_addr: (libc)Host Address Functions.
  849. * inet_aton: (libc)Host Address Functions.
  850. * inet_lnaof: (libc)Host Address Functions.
  851. * inet_makeaddr: (libc)Host Address Functions.
  852. * inet_netof: (libc)Host Address Functions.
  853. * inet_network: (libc)Host Address Functions.
  854. * inet_ntoa: (libc)Host Address Functions.
  855. * inet_ntop: (libc)Host Address Functions.
  856. * inet_pton: (libc)Host Address Functions.
  857. * INFINITY: (libc)Infinity and NaN.
  858. * initgroups: (libc)Setting Groups.
  859. * initstate: (libc)BSD Random.
  860. * initstate_r: (libc)BSD Random.
  861. * INLCR: (libc)Input Modes.
  862. * innetgr: (libc)Netgroup Membership.
  863. * INPCK: (libc)Input Modes.
  864. * ioctl: (libc)IOCTLs.
  865. * _IOFBF: (libc)Controlling Buffering.
  866. * _IOLBF: (libc)Controlling Buffering.
  867. * _IONBF: (libc)Controlling Buffering.
  868. * IPPORT_RESERVED: (libc)Ports.
  869. * IPPORT_USERRESERVED: (libc)Ports.
  870. * isalnum: (libc)Classification of Characters.
  871. * isalpha: (libc)Classification of Characters.
  872. * isascii: (libc)Classification of Characters.
  873. * isatty: (libc)Is It a Terminal.
  874. * isblank: (libc)Classification of Characters.
  875. * iscanonical: (libc)Floating Point Classes.
  876. * iscntrl: (libc)Classification of Characters.
  877. * isdigit: (libc)Classification of Characters.
  878. * iseqsig: (libc)FP Comparison Functions.
  879. * isfinite: (libc)Floating Point Classes.
  880. * isgraph: (libc)Classification of Characters.
  881. * isgreaterequal: (libc)FP Comparison Functions.
  882. * isgreater: (libc)FP Comparison Functions.
  883. * ISIG: (libc)Local Modes.
  884. * isinff: (libc)Floating Point Classes.
  885. * isinf: (libc)Floating Point Classes.
  886. * isinfl: (libc)Floating Point Classes.
  887. * islessequal: (libc)FP Comparison Functions.
  888. * islessgreater: (libc)FP Comparison Functions.
  889. * isless: (libc)FP Comparison Functions.
  890. * islower: (libc)Classification of Characters.
  891. * isnanf: (libc)Floating Point Classes.
  892. * isnan: (libc)Floating Point Classes.
  893. * isnan: (libc)Floating Point Classes.
  894. * isnanl: (libc)Floating Point Classes.
  895. * isnormal: (libc)Floating Point Classes.
  896. * isprint: (libc)Classification of Characters.
  897. * ispunct: (libc)Classification of Characters.
  898. * issignaling: (libc)Floating Point Classes.
  899. * isspace: (libc)Classification of Characters.
  900. * issubnormal: (libc)Floating Point Classes.
  901. * ISTRIP: (libc)Input Modes.
  902. * isunordered: (libc)FP Comparison Functions.
  903. * isupper: (libc)Classification of Characters.
  904. * iswalnum: (libc)Classification of Wide Characters.
  905. * iswalpha: (libc)Classification of Wide Characters.
  906. * iswblank: (libc)Classification of Wide Characters.
  907. * iswcntrl: (libc)Classification of Wide Characters.
  908. * iswctype: (libc)Classification of Wide Characters.
  909. * iswdigit: (libc)Classification of Wide Characters.
  910. * iswgraph: (libc)Classification of Wide Characters.
  911. * iswlower: (libc)Classification of Wide Characters.
  912. * iswprint: (libc)Classification of Wide Characters.
  913. * iswpunct: (libc)Classification of Wide Characters.
  914. * iswspace: (libc)Classification of Wide Characters.
  915. * iswupper: (libc)Classification of Wide Characters.
  916. * iswxdigit: (libc)Classification of Wide Characters.
  917. * isxdigit: (libc)Classification of Characters.
  918. * iszero: (libc)Floating Point Classes.
  919. * IXANY: (libc)Input Modes.
  920. * IXOFF: (libc)Input Modes.
  921. * IXON: (libc)Input Modes.
  922. * j0f: (libc)Special Functions.
  923. * j0: (libc)Special Functions.
  924. * j0l: (libc)Special Functions.
  925. * j1f: (libc)Special Functions.
  926. * j1: (libc)Special Functions.
  927. * j1l: (libc)Special Functions.
  928. * jnf: (libc)Special Functions.
  929. * jn: (libc)Special Functions.
  930. * jnl: (libc)Special Functions.
  931. * jrand48: (libc)SVID Random.
  932. * jrand48_r: (libc)SVID Random.
  933. * kill: (libc)Signaling Another Process.
  934. * killpg: (libc)Signaling Another Process.
  935. * l64a: (libc)Encode Binary Data.
  936. * labs: (libc)Absolute Value.
  937. * lcong48: (libc)SVID Random.
  938. * lcong48_r: (libc)SVID Random.
  939. * L_ctermid: (libc)Identifying the Terminal.
  940. * L_cuserid: (libc)Who Logged In.
  941. * ldexpf: (libc)Normalization Functions.
  942. * ldexp: (libc)Normalization Functions.
  943. * ldexpl: (libc)Normalization Functions.
  944. * ldiv: (libc)Integer Division.
  945. * lfind: (libc)Array Search Function.
  946. * lgammaf: (libc)Special Functions.
  947. * lgammaf_r: (libc)Special Functions.
  948. * lgamma: (libc)Special Functions.
  949. * lgammal: (libc)Special Functions.
  950. * lgammal_r: (libc)Special Functions.
  951. * lgamma_r: (libc)Special Functions.
  952. * LINE_MAX: (libc)Utility Limits.
  953. * link: (libc)Hard Links.
  954. * LINK_MAX: (libc)Limits for Files.
  955. * lio_listio64: (libc)Asynchronous Reads/Writes.
  956. * lio_listio: (libc)Asynchronous Reads/Writes.
  957. * listen: (libc)Listening.
  958. * llabs: (libc)Absolute Value.
  959. * lldiv: (libc)Integer Division.
  960. * llogbf: (libc)Exponents and Logarithms.
  961. * llogb: (libc)Exponents and Logarithms.
  962. * llogbl: (libc)Exponents and Logarithms.
  963. * llrintf: (libc)Rounding Functions.
  964. * llrint: (libc)Rounding Functions.
  965. * llrintl: (libc)Rounding Functions.
  966. * llroundf: (libc)Rounding Functions.
  967. * llround: (libc)Rounding Functions.
  968. * llroundl: (libc)Rounding Functions.
  969. * localeconv: (libc)The Lame Way to Locale Data.
  970. * localtime: (libc)Broken-down Time.
  971. * localtime_r: (libc)Broken-down Time.
  972. * log10f: (libc)Exponents and Logarithms.
  973. * log10: (libc)Exponents and Logarithms.
  974. * log10l: (libc)Exponents and Logarithms.
  975. * log1pf: (libc)Exponents and Logarithms.
  976. * log1p: (libc)Exponents and Logarithms.
  977. * log1pl: (libc)Exponents and Logarithms.
  978. * log2f: (libc)Exponents and Logarithms.
  979. * log2: (libc)Exponents and Logarithms.
  980. * log2l: (libc)Exponents and Logarithms.
  981. * logbf: (libc)Exponents and Logarithms.
  982. * logb: (libc)Exponents and Logarithms.
  983. * logbl: (libc)Exponents and Logarithms.
  984. * logf: (libc)Exponents and Logarithms.
  985. * login: (libc)Logging In and Out.
  986. * login_tty: (libc)Logging In and Out.
  987. * log: (libc)Exponents and Logarithms.
  988. * logl: (libc)Exponents and Logarithms.
  989. * logout: (libc)Logging In and Out.
  990. * logwtmp: (libc)Logging In and Out.
  991. * longjmp: (libc)Non-Local Details.
  992. * lrand48: (libc)SVID Random.
  993. * lrand48_r: (libc)SVID Random.
  994. * lrintf: (libc)Rounding Functions.
  995. * lrint: (libc)Rounding Functions.
  996. * lrintl: (libc)Rounding Functions.
  997. * lroundf: (libc)Rounding Functions.
  998. * lround: (libc)Rounding Functions.
  999. * lroundl: (libc)Rounding Functions.
  1000. * lsearch: (libc)Array Search Function.
  1001. * lseek64: (libc)File Position Primitive.
  1002. * lseek: (libc)File Position Primitive.
  1003. * lstat64: (libc)Reading Attributes.
  1004. * lstat: (libc)Reading Attributes.
  1005. * L_tmpnam: (libc)Temporary Files.
  1006. * lutimes: (libc)File Times.
  1007. * madvise: (libc)Memory-mapped I/O.
  1008. * makecontext: (libc)System V contexts.
  1009. * mallinfo: (libc)Statistics of Malloc.
  1010. * malloc: (libc)Basic Allocation.
  1011. * mallopt: (libc)Malloc Tunable Parameters.
  1012. * MAX_CANON: (libc)Limits for Files.
  1013. * MAX_INPUT: (libc)Limits for Files.
  1014. * MAXNAMLEN: (libc)Limits for Files.
  1015. * MAXSYMLINKS: (libc)Symbolic Links.
  1016. * MB_CUR_MAX: (libc)Selecting the Conversion.
  1017. * mblen: (libc)Non-reentrant Character Conversion.
  1018. * MB_LEN_MAX: (libc)Selecting the Conversion.
  1019. * mbrlen: (libc)Converting a Character.
  1020. * mbrtowc: (libc)Converting a Character.
  1021. * mbsinit: (libc)Keeping the state.
  1022. * mbsnrtowcs: (libc)Converting Strings.
  1023. * mbsrtowcs: (libc)Converting Strings.
  1024. * mbstowcs: (libc)Non-reentrant String Conversion.
  1025. * mbtowc: (libc)Non-reentrant Character Conversion.
  1026. * mcheck: (libc)Heap Consistency Checking.
  1027. * MDMBUF: (libc)Control Modes.
  1028. * memalign: (libc)Aligned Memory Blocks.
  1029. * memccpy: (libc)Copying Strings and Arrays.
  1030. * memchr: (libc)Search Functions.
  1031. * memcmp: (libc)String/Array Comparison.
  1032. * memcpy: (libc)Copying Strings and Arrays.
  1033. * memfrob: (libc)Trivial Encryption.
  1034. * memmem: (libc)Search Functions.
  1035. * memmove: (libc)Copying Strings and Arrays.
  1036. * mempcpy: (libc)Copying Strings and Arrays.
  1037. * memrchr: (libc)Search Functions.
  1038. * memset: (libc)Copying Strings and Arrays.
  1039. * mkdir: (libc)Creating Directories.
  1040. * mkdtemp: (libc)Temporary Files.
  1041. * mkfifo: (libc)FIFO Special Files.
  1042. * mknod: (libc)Making Special Files.
  1043. * mkstemp: (libc)Temporary Files.
  1044. * mktemp: (libc)Temporary Files.
  1045. * mktime: (libc)Broken-down Time.
  1046. * mlockall: (libc)Page Lock Functions.
  1047. * mlock: (libc)Page Lock Functions.
  1048. * mmap64: (libc)Memory-mapped I/O.
  1049. * mmap: (libc)Memory-mapped I/O.
  1050. * modff: (libc)Rounding Functions.
  1051. * modf: (libc)Rounding Functions.
  1052. * modfl: (libc)Rounding Functions.
  1053. * mount: (libc)Mount-Unmount-Remount.
  1054. * mprobe: (libc)Heap Consistency Checking.
  1055. * mrand48: (libc)SVID Random.
  1056. * mrand48_r: (libc)SVID Random.
  1057. * mremap: (libc)Memory-mapped I/O.
  1058. * MSG_DONTROUTE: (libc)Socket Data Options.
  1059. * MSG_OOB: (libc)Socket Data Options.
  1060. * MSG_PEEK: (libc)Socket Data Options.
  1061. * msync: (libc)Memory-mapped I/O.
  1062. * mtrace: (libc)Tracing malloc.
  1063. * munlockall: (libc)Page Lock Functions.
  1064. * munlock: (libc)Page Lock Functions.
  1065. * munmap: (libc)Memory-mapped I/O.
  1066. * muntrace: (libc)Tracing malloc.
  1067. * NAME_MAX: (libc)Limits for Files.
  1068. * nanf: (libc)FP Bit Twiddling.
  1069. * nan: (libc)FP Bit Twiddling.
  1070. * NAN: (libc)Infinity and NaN.
  1071. * nanl: (libc)FP Bit Twiddling.
  1072. * nanosleep: (libc)Sleeping.
  1073. * NCCS: (libc)Mode Data Types.
  1074. * nearbyintf: (libc)Rounding Functions.
  1075. * nearbyint: (libc)Rounding Functions.
  1076. * nearbyintl: (libc)Rounding Functions.
  1077. * nextafterf: (libc)FP Bit Twiddling.
  1078. * nextafter: (libc)FP Bit Twiddling.
  1079. * nextafterl: (libc)FP Bit Twiddling.
  1080. * nextdownf: (libc)FP Bit Twiddling.
  1081. * nextdown: (libc)FP Bit Twiddling.
  1082. * nextdownl: (libc)FP Bit Twiddling.
  1083. * nexttowardf: (libc)FP Bit Twiddling.
  1084. * nexttoward: (libc)FP Bit Twiddling.
  1085. * nexttowardl: (libc)FP Bit Twiddling.
  1086. * nextupf: (libc)FP Bit Twiddling.
  1087. * nextup: (libc)FP Bit Twiddling.
  1088. * nextupl: (libc)FP Bit Twiddling.
  1089. * nftw64: (libc)Working with Directory Trees.
  1090. * nftw: (libc)Working with Directory Trees.
  1091. * ngettext: (libc)Advanced gettext functions.
  1092. * NGROUPS_MAX: (libc)General Limits.
  1093. * nice: (libc)Traditional Scheduling Functions.
  1094. * nl_langinfo: (libc)The Elegant and Fast Way.
  1095. * NOFLSH: (libc)Local Modes.
  1096. * NOKERNINFO: (libc)Local Modes.
  1097. * nrand48: (libc)SVID Random.
  1098. * nrand48_r: (libc)SVID Random.
  1099. * NSIG: (libc)Standard Signals.
  1100. * ntohl: (libc)Byte Order.
  1101. * ntohs: (libc)Byte Order.
  1102. * ntp_adjtime: (libc)High Accuracy Clock.
  1103. * ntp_gettime: (libc)High Accuracy Clock.
  1104. * NULL: (libc)Null Pointer Constant.
  1105. * O_ACCMODE: (libc)Access Modes.
  1106. * O_APPEND: (libc)Operating Modes.
  1107. * O_ASYNC: (libc)Operating Modes.
  1108. * obstack_1grow_fast: (libc)Extra Fast Growing.
  1109. * obstack_1grow: (libc)Growing Objects.
  1110. * obstack_alignment_mask: (libc)Obstacks Data Alignment.
  1111. * obstack_alloc: (libc)Allocation in an Obstack.
  1112. * obstack_base: (libc)Status of an Obstack.
  1113. * obstack_blank_fast: (libc)Extra Fast Growing.
  1114. * obstack_blank: (libc)Growing Objects.
  1115. * obstack_chunk_size: (libc)Obstack Chunks.
  1116. * obstack_copy0: (libc)Allocation in an Obstack.
  1117. * obstack_copy: (libc)Allocation in an Obstack.
  1118. * obstack_finish: (libc)Growing Objects.
  1119. * obstack_free: (libc)Freeing Obstack Objects.
  1120. * obstack_grow0: (libc)Growing Objects.
  1121. * obstack_grow: (libc)Growing Objects.
  1122. * obstack_init: (libc)Preparing for Obstacks.
  1123. * obstack_int_grow_fast: (libc)Extra Fast Growing.
  1124. * obstack_int_grow: (libc)Growing Objects.
  1125. * obstack_next_free: (libc)Status of an Obstack.
  1126. * obstack_object_size: (libc)Growing Objects.
  1127. * obstack_object_size: (libc)Status of an Obstack.
  1128. * obstack_printf: (libc)Dynamic Output.
  1129. * obstack_ptr_grow_fast: (libc)Extra Fast Growing.
  1130. * obstack_ptr_grow: (libc)Growing Objects.
  1131. * obstack_room: (libc)Extra Fast Growing.
  1132. * obstack_vprintf: (libc)Variable Arguments Output.
  1133. * O_CREAT: (libc)Open-time Flags.
  1134. * O_EXCL: (libc)Open-time Flags.
  1135. * O_EXEC: (libc)Access Modes.
  1136. * O_EXLOCK: (libc)Open-time Flags.
  1137. * offsetof: (libc)Structure Measurement.
  1138. * O_FSYNC: (libc)Operating Modes.
  1139. * O_IGNORE_CTTY: (libc)Open-time Flags.
  1140. * O_NDELAY: (libc)Operating Modes.
  1141. * on_exit: (libc)Cleanups on Exit.
  1142. * ONLCR: (libc)Output Modes.
  1143. * O_NOATIME: (libc)Operating Modes.
  1144. * O_NOCTTY: (libc)Open-time Flags.
  1145. * ONOEOT: (libc)Output Modes.
  1146. * O_NOLINK: (libc)Open-time Flags.
  1147. * O_NONBLOCK: (libc)Open-time Flags.
  1148. * O_NONBLOCK: (libc)Operating Modes.
  1149. * O_NOTRANS: (libc)Open-time Flags.
  1150. * open64: (libc)Opening and Closing Files.
  1151. * opendir: (libc)Opening a Directory.
  1152. * open: (libc)Opening and Closing Files.
  1153. * openlog: (libc)openlog.
  1154. * OPEN_MAX: (libc)General Limits.
  1155. * open_memstream: (libc)String Streams.
  1156. * openpty: (libc)Pseudo-Terminal Pairs.
  1157. * OPOST: (libc)Output Modes.
  1158. * O_RDONLY: (libc)Access Modes.
  1159. * O_RDWR: (libc)Access Modes.
  1160. * O_READ: (libc)Access Modes.
  1161. * O_SHLOCK: (libc)Open-time Flags.
  1162. * O_SYNC: (libc)Operating Modes.
  1163. * O_TRUNC: (libc)Open-time Flags.
  1164. * O_WRITE: (libc)Access Modes.
  1165. * O_WRONLY: (libc)Access Modes.
  1166. * OXTABS: (libc)Output Modes.
  1167. * PA_FLAG_MASK: (libc)Parsing a Template String.
  1168. * PARENB: (libc)Control Modes.
  1169. * PARMRK: (libc)Input Modes.
  1170. * PARODD: (libc)Control Modes.
  1171. * parse_printf_format: (libc)Parsing a Template String.
  1172. * pathconf: (libc)Pathconf.
  1173. * PATH_MAX: (libc)Limits for Files.
  1174. * _PATH_UTMP: (libc)Manipulating the Database.
  1175. * _PATH_WTMP: (libc)Manipulating the Database.
  1176. * pause: (libc)Using Pause.
  1177. * pclose: (libc)Pipe to a Subprocess.
  1178. * PENDIN: (libc)Local Modes.
  1179. * perror: (libc)Error Messages.
  1180. * PF_FILE: (libc)Local Namespace Details.
  1181. * PF_INET6: (libc)Internet Namespace.
  1182. * PF_INET: (libc)Internet Namespace.
  1183. * PF_LOCAL: (libc)Local Namespace Details.
  1184. * PF_UNIX: (libc)Local Namespace Details.
  1185. * PIPE_BUF: (libc)Limits for Files.
  1186. * pipe: (libc)Creating a Pipe.
  1187. * popen: (libc)Pipe to a Subprocess.
  1188. * _POSIX2_C_DEV: (libc)System Options.
  1189. * _POSIX2_C_VERSION: (libc)Version Supported.
  1190. * _POSIX2_FORT_DEV: (libc)System Options.
  1191. * _POSIX2_FORT_RUN: (libc)System Options.
  1192. * _POSIX2_LOCALEDEF: (libc)System Options.
  1193. * _POSIX2_SW_DEV: (libc)System Options.
  1194. * _POSIX_CHOWN_RESTRICTED: (libc)Options for Files.
  1195. * posix_fallocate64: (libc)Storage Allocation.
  1196. * posix_fallocate: (libc)Storage Allocation.
  1197. * _POSIX_JOB_CONTROL: (libc)System Options.
  1198. * posix_memalign: (libc)Aligned Memory Blocks.
  1199. * _POSIX_NO_TRUNC: (libc)Options for Files.
  1200. * _POSIX_SAVED_IDS: (libc)System Options.
  1201. * _POSIX_VDISABLE: (libc)Options for Files.
  1202. * _POSIX_VERSION: (libc)Version Supported.
  1203. * pow10f: (libc)Exponents and Logarithms.
  1204. * pow10: (libc)Exponents and Logarithms.
  1205. * pow10l: (libc)Exponents and Logarithms.
  1206. * powf: (libc)Exponents and Logarithms.
  1207. * pow: (libc)Exponents and Logarithms.
  1208. * powl: (libc)Exponents and Logarithms.
  1209. * __ppc_get_timebase_freq: (libc)PowerPC.
  1210. * __ppc_get_timebase: (libc)PowerPC.
  1211. * __ppc_mdoio: (libc)PowerPC.
  1212. * __ppc_mdoom: (libc)PowerPC.
  1213. * __ppc_set_ppr_low: (libc)PowerPC.
  1214. * __ppc_set_ppr_med_high: (libc)PowerPC.
  1215. * __ppc_set_ppr_med: (libc)PowerPC.
  1216. * __ppc_set_ppr_med_low: (libc)PowerPC.
  1217. * __ppc_set_ppr_very_low: (libc)PowerPC.
  1218. * __ppc_yield: (libc)PowerPC.
  1219. * pread64: (libc)I/O Primitives.
  1220. * pread: (libc)I/O Primitives.
  1221. * printf: (libc)Formatted Output Functions.
  1222. * printf_size_info: (libc)Predefined Printf Handlers.
  1223. * printf_size: (libc)Predefined Printf Handlers.
  1224. * psignal: (libc)Signal Messages.
  1225. * pthread_getattr_default_np: (libc)Default Thread Attributes.
  1226. * pthread_getspecific: (libc)Thread-specific Data.
  1227. * pthread_key_create: (libc)Thread-specific Data.
  1228. * pthread_key_delete: (libc)Thread-specific Data.
  1229. * pthread_setattr_default_np: (libc)Default Thread Attributes.
  1230. * pthread_setspecific: (libc)Thread-specific Data.
  1231. * P_tmpdir: (libc)Temporary Files.
  1232. * ptsname: (libc)Allocation.
  1233. * ptsname_r: (libc)Allocation.
  1234. * putchar: (libc)Simple Output.
  1235. * putchar_unlocked: (libc)Simple Output.
  1236. * putc: (libc)Simple Output.
  1237. * putc_unlocked: (libc)Simple Output.
  1238. * putenv: (libc)Environment Access.
  1239. * putpwent: (libc)Writing a User Entry.
  1240. * puts: (libc)Simple Output.
  1241. * pututline: (libc)Manipulating the Database.
  1242. * pututxline: (libc)XPG Functions.
  1243. * putwchar: (libc)Simple Output.
  1244. * putwchar_unlocked: (libc)Simple Output.
  1245. * putwc: (libc)Simple Output.
  1246. * putwc_unlocked: (libc)Simple Output.
  1247. * putw: (libc)Simple Output.
  1248. * pwrite64: (libc)I/O Primitives.
  1249. * pwrite: (libc)I/O Primitives.
  1250. * qecvt: (libc)System V Number Conversion.
  1251. * qecvt_r: (libc)System V Number Conversion.
  1252. * qfcvt: (libc)System V Number Conversion.
  1253. * qfcvt_r: (libc)System V Number Conversion.
  1254. * qgcvt: (libc)System V Number Conversion.
  1255. * qsort: (libc)Array Sort Function.
  1256. * raise: (libc)Signaling Yourself.
  1257. * rand: (libc)ISO Random.
  1258. * RAND_MAX: (libc)ISO Random.
  1259. * random: (libc)BSD Random.
  1260. * random_r: (libc)BSD Random.
  1261. * rand_r: (libc)ISO Random.
  1262. * rawmemchr: (libc)Search Functions.
  1263. * readdir64: (libc)Reading/Closing Directory.
  1264. * readdir64_r: (libc)Reading/Closing Directory.
  1265. * readdir: (libc)Reading/Closing Directory.
  1266. * readdir_r: (libc)Reading/Closing Directory.
  1267. * read: (libc)I/O Primitives.
  1268. * readlink: (libc)Symbolic Links.
  1269. * readv: (libc)Scatter-Gather.
  1270. * realloc: (libc)Changing Block Size.
  1271. * realpath: (libc)Symbolic Links.
  1272. * recvfrom: (libc)Receiving Datagrams.
  1273. * recv: (libc)Receiving Data.
  1274. * recvmsg: (libc)Receiving Datagrams.
  1275. * RE_DUP_MAX: (libc)General Limits.
  1276. * regcomp: (libc)POSIX Regexp Compilation.
  1277. * regerror: (libc)Regexp Cleanup.
  1278. * regexec: (libc)Matching POSIX Regexps.
  1279. * regfree: (libc)Regexp Cleanup.
  1280. * register_printf_function: (libc)Registering New Conversions.
  1281. * remainderf: (libc)Remainder Functions.
  1282. * remainder: (libc)Remainder Functions.
  1283. * remainderl: (libc)Remainder Functions.
  1284. * remove: (libc)Deleting Files.
  1285. * rename: (libc)Renaming Files.
  1286. * rewinddir: (libc)Random Access Directory.
  1287. * rewind: (libc)File Positioning.
  1288. * rindex: (libc)Search Functions.
  1289. * rintf: (libc)Rounding Functions.
  1290. * rint: (libc)Rounding Functions.
  1291. * rintl: (libc)Rounding Functions.
  1292. * RLIM_INFINITY: (libc)Limits on Resources.
  1293. * rmdir: (libc)Deleting Files.
  1294. * R_OK: (libc)Testing File Access.
  1295. * roundevenf: (libc)Rounding Functions.
  1296. * roundeven: (libc)Rounding Functions.
  1297. * roundevenl: (libc)Rounding Functions.
  1298. * roundf: (libc)Rounding Functions.
  1299. * round: (libc)Rounding Functions.
  1300. * roundl: (libc)Rounding Functions.
  1301. * rpmatch: (libc)Yes-or-No Questions.
  1302. * SA_NOCLDSTOP: (libc)Flags for Sigaction.
  1303. * SA_ONSTACK: (libc)Flags for Sigaction.
  1304. * SA_RESTART: (libc)Flags for Sigaction.
  1305. * sbrk: (libc)Resizing the Data Segment.
  1306. * scalbf: (libc)Normalization Functions.
  1307. * scalb: (libc)Normalization Functions.
  1308. * scalbl: (libc)Normalization Functions.
  1309. * scalblnf: (libc)Normalization Functions.
  1310. * scalbln: (libc)Normalization Functions.
  1311. * scalblnl: (libc)Normalization Functions.
  1312. * scalbnf: (libc)Normalization Functions.
  1313. * scalbn: (libc)Normalization Functions.
  1314. * scalbnl: (libc)Normalization Functions.
  1315. * scandir64: (libc)Scanning Directory Content.
  1316. * scandir: (libc)Scanning Directory Content.
  1317. * scanf: (libc)Formatted Input Functions.
  1318. * sched_getaffinity: (libc)CPU Affinity.
  1319. * sched_getparam: (libc)Basic Scheduling Functions.
  1320. * sched_get_priority_max: (libc)Basic Scheduling Functions.
  1321. * sched_get_priority_min: (libc)Basic Scheduling Functions.
  1322. * sched_getscheduler: (libc)Basic Scheduling Functions.
  1323. * sched_rr_get_interval: (libc)Basic Scheduling Functions.
  1324. * sched_setaffinity: (libc)CPU Affinity.
  1325. * sched_setparam: (libc)Basic Scheduling Functions.
  1326. * sched_setscheduler: (libc)Basic Scheduling Functions.
  1327. * sched_yield: (libc)Basic Scheduling Functions.
  1328. * secure_getenv: (libc)Environment Access.
  1329. * seed48: (libc)SVID Random.
  1330. * seed48_r: (libc)SVID Random.
  1331. * SEEK_CUR: (libc)File Positioning.
  1332. * seekdir: (libc)Random Access Directory.
  1333. * SEEK_END: (libc)File Positioning.
  1334. * SEEK_SET: (libc)File Positioning.
  1335. * select: (libc)Waiting for I/O.
  1336. * sem_close: (libc)Semaphores.
  1337. * semctl: (libc)Semaphores.
  1338. * sem_destroy: (libc)Semaphores.
  1339. * semget: (libc)Semaphores.
  1340. * sem_getvalue: (libc)Semaphores.
  1341. * sem_init: (libc)Semaphores.
  1342. * sem_open: (libc)Semaphores.
  1343. * semop: (libc)Semaphores.
  1344. * sem_post: (libc)Semaphores.
  1345. * semtimedop: (libc)Semaphores.
  1346. * sem_timedwait: (libc)Semaphores.
  1347. * sem_trywait: (libc)Semaphores.
  1348. * sem_unlink: (libc)Semaphores.
  1349. * sem_wait: (libc)Semaphores.
  1350. * send: (libc)Sending Data.
  1351. * sendmsg: (libc)Receiving Datagrams.
  1352. * sendto: (libc)Sending Datagrams.
  1353. * setbuffer: (libc)Controlling Buffering.
  1354. * setbuf: (libc)Controlling Buffering.
  1355. * setcontext: (libc)System V contexts.
  1356. * setdomainname: (libc)Host Identification.
  1357. * setegid: (libc)Setting Groups.
  1358. * setenv: (libc)Environment Access.
  1359. * seteuid: (libc)Setting User ID.
  1360. * setfsent: (libc)fstab.
  1361. * setgid: (libc)Setting Groups.
  1362. * setgrent: (libc)Scanning All Groups.
  1363. * setgroups: (libc)Setting Groups.
  1364. * sethostent: (libc)Host Names.
  1365. * sethostid: (libc)Host Identification.
  1366. * sethostname: (libc)Host Identification.
  1367. * setitimer: (libc)Setting an Alarm.
  1368. * setjmp: (libc)Non-Local Details.
  1369. * setkey: (libc)DES Encryption.
  1370. * setkey_r: (libc)DES Encryption.
  1371. * setlinebuf: (libc)Controlling Buffering.
  1372. * setlocale: (libc)Setting the Locale.
  1373. * setlogmask: (libc)setlogmask.
  1374. * setmntent: (libc)mtab.
  1375. * setnetent: (libc)Networks Database.
  1376. * setnetgrent: (libc)Lookup Netgroup.
  1377. * setpayloadf: (libc)FP Bit Twiddling.
  1378. * setpayload: (libc)FP Bit Twiddling.
  1379. * setpayloadl: (libc)FP Bit Twiddling.
  1380. * setpayloadsigf: (libc)FP Bit Twiddling.
  1381. * setpayloadsig: (libc)FP Bit Twiddling.
  1382. * setpayloadsigl: (libc)FP Bit Twiddling.
  1383. * setpgid: (libc)Process Group Functions.
  1384. * setpgrp: (libc)Process Group Functions.
  1385. * setpriority: (libc)Traditional Scheduling Functions.
  1386. * setprotoent: (libc)Protocols Database.
  1387. * setpwent: (libc)Scanning All Users.
  1388. * setregid: (libc)Setting Groups.
  1389. * setreuid: (libc)Setting User ID.
  1390. * setrlimit64: (libc)Limits on Resources.
  1391. * setrlimit: (libc)Limits on Resources.
  1392. * setservent: (libc)Services Database.
  1393. * setsid: (libc)Process Group Functions.
  1394. * setsockopt: (libc)Socket Option Functions.
  1395. * setstate: (libc)BSD Random.
  1396. * setstate_r: (libc)BSD Random.
  1397. * settimeofday: (libc)High-Resolution Calendar.
  1398. * setuid: (libc)Setting User ID.
  1399. * setutent: (libc)Manipulating the Database.
  1400. * setutxent: (libc)XPG Functions.
  1401. * setvbuf: (libc)Controlling Buffering.
  1402. * shm_open: (libc)Memory-mapped I/O.
  1403. * shm_unlink: (libc)Memory-mapped I/O.
  1404. * shutdown: (libc)Closing a Socket.
  1405. * S_IFMT: (libc)Testing File Type.
  1406. * SIGABRT: (libc)Program Error Signals.
  1407. * sigaction: (libc)Advanced Signal Handling.
  1408. * sigaddset: (libc)Signal Sets.
  1409. * SIGALRM: (libc)Alarm Signals.
  1410. * sigaltstack: (libc)Signal Stack.
  1411. * sigblock: (libc)BSD Signal Handling.
  1412. * SIGBUS: (libc)Program Error Signals.
  1413. * SIGCHLD: (libc)Job Control Signals.
  1414. * SIGCLD: (libc)Job Control Signals.
  1415. * SIGCONT: (libc)Job Control Signals.
  1416. * sigdelset: (libc)Signal Sets.
  1417. * sigemptyset: (libc)Signal Sets.
  1418. * SIGEMT: (libc)Program Error Signals.
  1419. * SIG_ERR: (libc)Basic Signal Handling.
  1420. * sigfillset: (libc)Signal Sets.
  1421. * SIGFPE: (libc)Program Error Signals.
  1422. * SIGHUP: (libc)Termination Signals.
  1423. * SIGILL: (libc)Program Error Signals.
  1424. * SIGINFO: (libc)Miscellaneous Signals.
  1425. * siginterrupt: (libc)BSD Signal Handling.
  1426. * SIGINT: (libc)Termination Signals.
  1427. * SIGIO: (libc)Asynchronous I/O Signals.
  1428. * SIGIOT: (libc)Program Error Signals.
  1429. * sigismember: (libc)Signal Sets.
  1430. * SIGKILL: (libc)Termination Signals.
  1431. * siglongjmp: (libc)Non-Local Exits and Signals.
  1432. * SIGLOST: (libc)Operation Error Signals.
  1433. * sigmask: (libc)BSD Signal Handling.
  1434. * signal: (libc)Basic Signal Handling.
  1435. * signbit: (libc)FP Bit Twiddling.
  1436. * significandf: (libc)Normalization Functions.
  1437. * significand: (libc)Normalization Functions.
  1438. * significandl: (libc)Normalization Functions.
  1439. * sigpause: (libc)BSD Signal Handling.
  1440. * sigpending: (libc)Checking for Pending Signals.
  1441. * SIGPIPE: (libc)Operation Error Signals.
  1442. * SIGPOLL: (libc)Asynchronous I/O Signals.
  1443. * sigprocmask: (libc)Process Signal Mask.
  1444. * SIGPROF: (libc)Alarm Signals.
  1445. * SIGQUIT: (libc)Termination Signals.
  1446. * SIGSEGV: (libc)Program Error Signals.
  1447. * sigsetjmp: (libc)Non-Local Exits and Signals.
  1448. * sigsetmask: (libc)BSD Signal Handling.
  1449. * sigstack: (libc)Signal Stack.
  1450. * SIGSTOP: (libc)Job Control Signals.
  1451. * sigsuspend: (libc)Sigsuspend.
  1452. * SIGSYS: (libc)Program Error Signals.
  1453. * SIGTERM: (libc)Termination Signals.
  1454. * SIGTRAP: (libc)Program Error Signals.
  1455. * SIGTSTP: (libc)Job Control Signals.
  1456. * SIGTTIN: (libc)Job Control Signals.
  1457. * SIGTTOU: (libc)Job Control Signals.
  1458. * SIGURG: (libc)Asynchronous I/O Signals.
  1459. * SIGUSR1: (libc)Miscellaneous Signals.
  1460. * SIGUSR2: (libc)Miscellaneous Signals.
  1461. * SIGVTALRM: (libc)Alarm Signals.
  1462. * SIGWINCH: (libc)Miscellaneous Signals.
  1463. * SIGXCPU: (libc)Operation Error Signals.
  1464. * SIGXFSZ: (libc)Operation Error Signals.
  1465. * sincosf: (libc)Trig Functions.
  1466. * sincos: (libc)Trig Functions.
  1467. * sincosl: (libc)Trig Functions.
  1468. * sinf: (libc)Trig Functions.
  1469. * sinhf: (libc)Hyperbolic Functions.
  1470. * sinh: (libc)Hyperbolic Functions.
  1471. * sinhl: (libc)Hyperbolic Functions.
  1472. * sin: (libc)Trig Functions.
  1473. * sinl: (libc)Trig Functions.
  1474. * S_ISBLK: (libc)Testing File Type.
  1475. * S_ISCHR: (libc)Testing File Type.
  1476. * S_ISDIR: (libc)Testing File Type.
  1477. * S_ISFIFO: (libc)Testing File Type.
  1478. * S_ISLNK: (libc)Testing File Type.
  1479. * S_ISREG: (libc)Testing File Type.
  1480. * S_ISSOCK: (libc)Testing File Type.
  1481. * sleep: (libc)Sleeping.
  1482. * SNANF: (libc)Infinity and NaN.
  1483. * SNAN: (libc)Infinity and NaN.
  1484. * SNANL: (libc)Infinity and NaN.
  1485. * snprintf: (libc)Formatted Output Functions.
  1486. * SOCK_DGRAM: (libc)Communication Styles.
  1487. * socket: (libc)Creating a Socket.
  1488. * socketpair: (libc)Socket Pairs.
  1489. * SOCK_RAW: (libc)Communication Styles.
  1490. * SOCK_RDM: (libc)Communication Styles.
  1491. * SOCK_SEQPACKET: (libc)Communication Styles.
  1492. * SOCK_STREAM: (libc)Communication Styles.
  1493. * SOL_SOCKET: (libc)Socket-Level Options.
  1494. * sprintf: (libc)Formatted Output Functions.
  1495. * sqrtf: (libc)Exponents and Logarithms.
  1496. * sqrt: (libc)Exponents and Logarithms.
  1497. * sqrtl: (libc)Exponents and Logarithms.
  1498. * srand48: (libc)SVID Random.
  1499. * srand48_r: (libc)SVID Random.
  1500. * srand: (libc)ISO Random.
  1501. * srandom: (libc)BSD Random.
  1502. * srandom_r: (libc)BSD Random.
  1503. * sscanf: (libc)Formatted Input Functions.
  1504. * ssignal: (libc)Basic Signal Handling.
  1505. * SSIZE_MAX: (libc)General Limits.
  1506. * stat64: (libc)Reading Attributes.
  1507. * stat: (libc)Reading Attributes.
  1508. * stime: (libc)Simple Calendar Time.
  1509. * stpcpy: (libc)Copying Strings and Arrays.
  1510. * stpncpy: (libc)Truncating Strings.
  1511. * strcasecmp: (libc)String/Array Comparison.
  1512. * strcasestr: (libc)Search Functions.
  1513. * strcat: (libc)Concatenating Strings.
  1514. * strchr: (libc)Search Functions.
  1515. * strchrnul: (libc)Search Functions.
  1516. * strcmp: (libc)String/Array Comparison.
  1517. * strcoll: (libc)Collation Functions.
  1518. * strcpy: (libc)Copying Strings and Arrays.
  1519. * strcspn: (libc)Search Functions.
  1520. * strdupa: (libc)Copying Strings and Arrays.
  1521. * strdup: (libc)Copying Strings and Arrays.
  1522. * STREAM_MAX: (libc)General Limits.
  1523. * strerror: (libc)Error Messages.
  1524. * strerror_r: (libc)Error Messages.
  1525. * strfmon: (libc)Formatting Numbers.
  1526. * strfromd: (libc)Printing of Floats.
  1527. * strfromf: (libc)Printing of Floats.
  1528. * strfroml: (libc)Printing of Floats.
  1529. * strfry: (libc)strfry.
  1530. * strftime: (libc)Formatting Calendar Time.
  1531. * strlen: (libc)String Length.
  1532. * strncasecmp: (libc)String/Array Comparison.
  1533. * strncat: (libc)Truncating Strings.
  1534. * strncmp: (libc)String/Array Comparison.
  1535. * strncpy: (libc)Truncating Strings.
  1536. * strndupa: (libc)Truncating Strings.
  1537. * strndup: (libc)Truncating Strings.
  1538. * strnlen: (libc)String Length.
  1539. * strpbrk: (libc)Search Functions.
  1540. * strptime: (libc)Low-Level Time String Parsing.
  1541. * strrchr: (libc)Search Functions.
  1542. * strsep: (libc)Finding Tokens in a String.
  1543. * strsignal: (libc)Signal Messages.
  1544. * strspn: (libc)Search Functions.
  1545. * strstr: (libc)Search Functions.
  1546. * strtod: (libc)Parsing of Floats.
  1547. * strtof: (libc)Parsing of Floats.
  1548. * strtoimax: (libc)Parsing of Integers.
  1549. * strtok: (libc)Finding Tokens in a String.
  1550. * strtok_r: (libc)Finding Tokens in a String.
  1551. * strtold: (libc)Parsing of Floats.
  1552. * strtol: (libc)Parsing of Integers.
  1553. * strtoll: (libc)Parsing of Integers.
  1554. * strtoq: (libc)Parsing of Integers.
  1555. * strtoul: (libc)Parsing of Integers.
  1556. * strtoull: (libc)Parsing of Integers.
  1557. * strtoumax: (libc)Parsing of Integers.
  1558. * strtouq: (libc)Parsing of Integers.
  1559. * strverscmp: (libc)String/Array Comparison.
  1560. * strxfrm: (libc)Collation Functions.
  1561. * stty: (libc)BSD Terminal Modes.
  1562. * S_TYPEISMQ: (libc)Testing File Type.
  1563. * S_TYPEISSEM: (libc)Testing File Type.
  1564. * S_TYPEISSHM: (libc)Testing File Type.
  1565. * SUN_LEN: (libc)Local Namespace Details.
  1566. * swapcontext: (libc)System V contexts.
  1567. * swprintf: (libc)Formatted Output Functions.
  1568. * swscanf: (libc)Formatted Input Functions.
  1569. * symlink: (libc)Symbolic Links.
  1570. * sync: (libc)Synchronizing I/O.
  1571. * syscall: (libc)System Calls.
  1572. * sysconf: (libc)Sysconf Definition.
  1573. * sysctl: (libc)System Parameters.
  1574. * syslog: (libc)syslog; vsyslog.
  1575. * system: (libc)Running a Command.
  1576. * sysv_signal: (libc)Basic Signal Handling.
  1577. * tanf: (libc)Trig Functions.
  1578. * tanhf: (libc)Hyperbolic Functions.
  1579. * tanh: (libc)Hyperbolic Functions.
  1580. * tanhl: (libc)Hyperbolic Functions.
  1581. * tan: (libc)Trig Functions.
  1582. * tanl: (libc)Trig Functions.
  1583. * tcdrain: (libc)Line Control.
  1584. * tcflow: (libc)Line Control.
  1585. * tcflush: (libc)Line Control.
  1586. * tcgetattr: (libc)Mode Functions.
  1587. * tcgetpgrp: (libc)Terminal Access Functions.
  1588. * tcgetsid: (libc)Terminal Access Functions.
  1589. * tcsendbreak: (libc)Line Control.
  1590. * tcsetattr: (libc)Mode Functions.
  1591. * tcsetpgrp: (libc)Terminal Access Functions.
  1592. * tdelete: (libc)Tree Search Function.
  1593. * tdestroy: (libc)Tree Search Function.
  1594. * telldir: (libc)Random Access Directory.
  1595. * tempnam: (libc)Temporary Files.
  1596. * textdomain: (libc)Locating gettext catalog.
  1597. * tfind: (libc)Tree Search Function.
  1598. * tgammaf: (libc)Special Functions.
  1599. * tgamma: (libc)Special Functions.
  1600. * tgammal: (libc)Special Functions.
  1601. * timegm: (libc)Broken-down Time.
  1602. * time: (libc)Simple Calendar Time.
  1603. * timelocal: (libc)Broken-down Time.
  1604. * times: (libc)Processor Time.
  1605. * tmpfile64: (libc)Temporary Files.
  1606. * tmpfile: (libc)Temporary Files.
  1607. * TMP_MAX: (libc)Temporary Files.
  1608. * tmpnam: (libc)Temporary Files.
  1609. * tmpnam_r: (libc)Temporary Files.
  1610. * toascii: (libc)Case Conversion.
  1611. * _tolower: (libc)Case Conversion.
  1612. * tolower: (libc)Case Conversion.
  1613. * TOSTOP: (libc)Local Modes.
  1614. * totalorderf: (libc)FP Comparison Functions.
  1615. * totalorder: (libc)FP Comparison Functions.
  1616. * totalorderl: (libc)FP Comparison Functions.
  1617. * totalordermagf: (libc)FP Comparison Functions.
  1618. * totalordermag: (libc)FP Comparison Functions.
  1619. * totalordermagl: (libc)FP Comparison Functions.
  1620. * _toupper: (libc)Case Conversion.
  1621. * toupper: (libc)Case Conversion.
  1622. * towctrans: (libc)Wide Character Case Conversion.
  1623. * towlower: (libc)Wide Character Case Conversion.
  1624. * towupper: (libc)Wide Character Case Conversion.
  1625. * truncate64: (libc)File Size.
  1626. * truncate: (libc)File Size.
  1627. * truncf: (libc)Rounding Functions.
  1628. * trunc: (libc)Rounding Functions.
  1629. * truncl: (libc)Rounding Functions.
  1630. * tsearch: (libc)Tree Search Function.
  1631. * ttyname: (libc)Is It a Terminal.
  1632. * ttyname_r: (libc)Is It a Terminal.
  1633. * twalk: (libc)Tree Search Function.
  1634. * TZNAME_MAX: (libc)General Limits.
  1635. * tzset: (libc)Time Zone Functions.
  1636. * ufromfpf: (libc)Rounding Functions.
  1637. * ufromfp: (libc)Rounding Functions.
  1638. * ufromfpl: (libc)Rounding Functions.
  1639. * ufromfpxf: (libc)Rounding Functions.
  1640. * ufromfpx: (libc)Rounding Functions.
  1641. * ufromfpxl: (libc)Rounding Functions.
  1642. * ulimit: (libc)Limits on Resources.
  1643. * umask: (libc)Setting Permissions.
  1644. * umount2: (libc)Mount-Unmount-Remount.
  1645. * umount: (libc)Mount-Unmount-Remount.
  1646. * uname: (libc)Platform Type.
  1647. * ungetc: (libc)How Unread.
  1648. * ungetwc: (libc)How Unread.
  1649. * unlink: (libc)Deleting Files.
  1650. * unlockpt: (libc)Allocation.
  1651. * unsetenv: (libc)Environment Access.
  1652. * updwtmp: (libc)Manipulating the Database.
  1653. * utime: (libc)File Times.
  1654. * utimes: (libc)File Times.
  1655. * utmpname: (libc)Manipulating the Database.
  1656. * utmpxname: (libc)XPG Functions.
  1657. * va_arg: (libc)Argument Macros.
  1658. * __va_copy: (libc)Argument Macros.
  1659. * va_copy: (libc)Argument Macros.
  1660. * va_end: (libc)Argument Macros.
  1661. * valloc: (libc)Aligned Memory Blocks.
  1662. * vasprintf: (libc)Variable Arguments Output.
  1663. * va_start: (libc)Argument Macros.
  1664. * VDISCARD: (libc)Other Special.
  1665. * VDSUSP: (libc)Signal Characters.
  1666. * VEOF: (libc)Editing Characters.
  1667. * VEOL2: (libc)Editing Characters.
  1668. * VEOL: (libc)Editing Characters.
  1669. * VERASE: (libc)Editing Characters.
  1670. * verr: (libc)Error Messages.
  1671. * verrx: (libc)Error Messages.
  1672. * versionsort64: (libc)Scanning Directory Content.
  1673. * versionsort: (libc)Scanning Directory Content.
  1674. * vfork: (libc)Creating a Process.
  1675. * vfprintf: (libc)Variable Arguments Output.
  1676. * vfscanf: (libc)Variable Arguments Input.
  1677. * vfwprintf: (libc)Variable Arguments Output.
  1678. * vfwscanf: (libc)Variable Arguments Input.
  1679. * VINTR: (libc)Signal Characters.
  1680. * VKILL: (libc)Editing Characters.
  1681. * vlimit: (libc)Limits on Resources.
  1682. * VLNEXT: (libc)Other Special.
  1683. * VMIN: (libc)Noncanonical Input.
  1684. * vprintf: (libc)Variable Arguments Output.
  1685. * VQUIT: (libc)Signal Characters.
  1686. * VREPRINT: (libc)Editing Characters.
  1687. * vscanf: (libc)Variable Arguments Input.
  1688. * vsnprintf: (libc)Variable Arguments Output.
  1689. * vsprintf: (libc)Variable Arguments Output.
  1690. * vsscanf: (libc)Variable Arguments Input.
  1691. * VSTART: (libc)Start/Stop Characters.
  1692. * VSTATUS: (libc)Other Special.
  1693. * VSTOP: (libc)Start/Stop Characters.
  1694. * VSUSP: (libc)Signal Characters.
  1695. * vswprintf: (libc)Variable Arguments Output.
  1696. * vswscanf: (libc)Variable Arguments Input.
  1697. * vsyslog: (libc)syslog; vsyslog.
  1698. * VTIME: (libc)Noncanonical Input.
  1699. * vtimes: (libc)Resource Usage.
  1700. * vwarn: (libc)Error Messages.
  1701. * vwarnx: (libc)Error Messages.
  1702. * VWERASE: (libc)Editing Characters.
  1703. * vwprintf: (libc)Variable Arguments Output.
  1704. * vwscanf: (libc)Variable Arguments Input.
  1705. * wait3: (libc)BSD Wait Functions.
  1706. * wait4: (libc)Process Completion.
  1707. * wait: (libc)Process Completion.
  1708. * waitpid: (libc)Process Completion.
  1709. * warn: (libc)Error Messages.
  1710. * warnx: (libc)Error Messages.
  1711. * WCHAR_MAX: (libc)Extended Char Intro.
  1712. * WCHAR_MIN: (libc)Extended Char Intro.
  1713. * WCOREDUMP: (libc)Process Completion Status.
  1714. * wcpcpy: (libc)Copying Strings and Arrays.
  1715. * wcpncpy: (libc)Truncating Strings.
  1716. * wcrtomb: (libc)Converting a Character.
  1717. * wcscasecmp: (libc)String/Array Comparison.
  1718. * wcscat: (libc)Concatenating Strings.
  1719. * wcschr: (libc)Search Functions.
  1720. * wcschrnul: (libc)Search Functions.
  1721. * wcscmp: (libc)String/Array Comparison.
  1722. * wcscoll: (libc)Collation Functions.
  1723. * wcscpy: (libc)Copying Strings and Arrays.
  1724. * wcscspn: (libc)Search Functions.
  1725. * wcsdup: (libc)Copying Strings and Arrays.
  1726. * wcsftime: (libc)Formatting Calendar Time.
  1727. * wcslen: (libc)String Length.
  1728. * wcsncasecmp: (libc)String/Array Comparison.
  1729. * wcsncat: (libc)Truncating Strings.
  1730. * wcsncmp: (libc)String/Array Comparison.
  1731. * wcsncpy: (libc)Truncating Strings.
  1732. * wcsnlen: (libc)String Length.
  1733. * wcsnrtombs: (libc)Converting Strings.
  1734. * wcspbrk: (libc)Search Functions.
  1735. * wcsrchr: (libc)Search Functions.
  1736. * wcsrtombs: (libc)Converting Strings.
  1737. * wcsspn: (libc)Search Functions.
  1738. * wcsstr: (libc)Search Functions.
  1739. * wcstod: (libc)Parsing of Floats.
  1740. * wcstof: (libc)Parsing of Floats.
  1741. * wcstoimax: (libc)Parsing of Integers.
  1742. * wcstok: (libc)Finding Tokens in a String.
  1743. * wcstold: (libc)Parsing of Floats.
  1744. * wcstol: (libc)Parsing of Integers.
  1745. * wcstoll: (libc)Parsing of Integers.
  1746. * wcstombs: (libc)Non-reentrant String Conversion.
  1747. * wcstoq: (libc)Parsing of Integers.
  1748. * wcstoul: (libc)Parsing of Integers.
  1749. * wcstoull: (libc)Parsing of Integers.
  1750. * wcstoumax: (libc)Parsing of Integers.
  1751. * wcstouq: (libc)Parsing of Integers.
  1752. * wcswcs: (libc)Search Functions.
  1753. * wcsxfrm: (libc)Collation Functions.
  1754. * wctob: (libc)Converting a Character.
  1755. * wctomb: (libc)Non-reentrant Character Conversion.
  1756. * wctrans: (libc)Wide Character Case Conversion.
  1757. * wctype: (libc)Classification of Wide Characters.
  1758. * WEOF: (libc)EOF and Errors.
  1759. * WEOF: (libc)Extended Char Intro.
  1760. * WEXITSTATUS: (libc)Process Completion Status.
  1761. * WIFEXITED: (libc)Process Completion Status.
  1762. * WIFSIGNALED: (libc)Process Completion Status.
  1763. * WIFSTOPPED: (libc)Process Completion Status.
  1764. * wmemchr: (libc)Search Functions.
  1765. * wmemcmp: (libc)String/Array Comparison.
  1766. * wmemcpy: (libc)Copying Strings and Arrays.
  1767. * wmemmove: (libc)Copying Strings and Arrays.
  1768. * wmempcpy: (libc)Copying Strings and Arrays.
  1769. * wmemset: (libc)Copying Strings and Arrays.
  1770. * W_OK: (libc)Testing File Access.
  1771. * wordexp: (libc)Calling Wordexp.
  1772. * wordfree: (libc)Calling Wordexp.
  1773. * wprintf: (libc)Formatted Output Functions.
  1774. * write: (libc)I/O Primitives.
  1775. * writev: (libc)Scatter-Gather.
  1776. * wscanf: (libc)Formatted Input Functions.
  1777. * WSTOPSIG: (libc)Process Completion Status.
  1778. * WTERMSIG: (libc)Process Completion Status.
  1779. * X_OK: (libc)Testing File Access.
  1780. * y0f: (libc)Special Functions.
  1781. * y0: (libc)Special Functions.
  1782. * y0l: (libc)Special Functions.
  1783. * y1f: (libc)Special Functions.
  1784. * y1: (libc)Special Functions.
  1785. * y1l: (libc)Special Functions.
  1786. * ynf: (libc)Special Functions.
  1787. * yn: (libc)Special Functions.
  1788. * ynl: (libc)Special Functions.
  1789. END-INFO-DIR-ENTRY
  1790. 
  1791. File: libc.info, Node: CPU Time, Next: Processor Time, Up: Processor And CPU Time
  1792. 21.3.1 CPU Time Inquiry
  1793. -----------------------
  1794. To get a process’ CPU time, you can use the ‘clock’ function. This
  1795. facility is declared in the header file ‘time.h’.
  1796. In typical usage, you call the ‘clock’ function at the beginning and
  1797. end of the interval you want to time, subtract the values, and then
  1798. divide by ‘CLOCKS_PER_SEC’ (the number of clock ticks per second) to get
  1799. processor time, like this:
  1800. #include <time.h>
  1801. clock_t start, end;
  1802. double cpu_time_used;
  1803. start = clock();
  1804. … /* Do the work. */
  1805. end = clock();
  1806. cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
  1807. Do not use a single CPU time as an amount of time; it doesn’t work
  1808. that way. Either do a subtraction as shown above or query processor
  1809. time directly. *Note Processor Time::.
  1810. Different computers and operating systems vary wildly in how they
  1811. keep track of CPU time. It’s common for the internal processor clock to
  1812. have a resolution somewhere between a hundredth and millionth of a
  1813. second.
  1814. -- Macro: int CLOCKS_PER_SEC
  1815. The value of this macro is the number of clock ticks per second
  1816. measured by the ‘clock’ function. POSIX requires that this value
  1817. be one million independent of the actual resolution.
  1818. -- Data Type: clock_t
  1819. This is the type of the value returned by the ‘clock’ function.
  1820. Values of type ‘clock_t’ are numbers of clock ticks.
  1821. -- Function: clock_t clock (void)
  1822. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1823. Concepts::.
  1824. This function returns the calling process’ current CPU time. If
  1825. the CPU time is not available or cannot be represented, ‘clock’
  1826. returns the value ‘(clock_t)(-1)’.
  1827. 
  1828. File: libc.info, Node: Processor Time, Prev: CPU Time, Up: Processor And CPU Time
  1829. 21.3.2 Processor Time Inquiry
  1830. -----------------------------
  1831. The ‘times’ function returns information about a process’ consumption of
  1832. processor time in a ‘struct tms’ object, in addition to the process’ CPU
  1833. time. *Note Time Basics::. You should include the header file
  1834. ‘sys/times.h’ to use this facility.
  1835. -- Data Type: struct tms
  1836. The ‘tms’ structure is used to return information about process
  1837. times. It contains at least the following members:
  1838. ‘clock_t tms_utime’
  1839. This is the total processor time the calling process has used
  1840. in executing the instructions of its program.
  1841. ‘clock_t tms_stime’
  1842. This is the processor time the system has used on behalf of
  1843. the calling process.
  1844. ‘clock_t tms_cutime’
  1845. This is the sum of the ‘tms_utime’ values and the ‘tms_cutime’
  1846. values of all terminated child processes of the calling
  1847. process, whose status has been reported to the parent process
  1848. by ‘wait’ or ‘waitpid’; see *note Process Completion::. In
  1849. other words, it represents the total processor time used in
  1850. executing the instructions of all the terminated child
  1851. processes of the calling process, excluding child processes
  1852. which have not yet been reported by ‘wait’ or ‘waitpid’.
  1853. ‘clock_t tms_cstime’
  1854. This is similar to ‘tms_cutime’, but represents the total
  1855. processor time the system has used on behalf of all the
  1856. terminated child processes of the calling process.
  1857. All of the times are given in numbers of clock ticks. Unlike CPU
  1858. time, these are the actual amounts of time; not relative to any
  1859. event. *Note Creating a Process::.
  1860. -- Macro: int CLK_TCK
  1861. This is an obsolete name for the number of clock ticks per second.
  1862. Use ‘sysconf (_SC_CLK_TCK)’ instead.
  1863. -- Function: clock_t times (struct tms *BUFFER)
  1864. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1865. Concepts::.
  1866. The ‘times’ function stores the processor time information for the
  1867. calling process in BUFFER.
  1868. The return value is the number of clock ticks since an arbitrary
  1869. point in the past, e.g. since system start-up. ‘times’ returns
  1870. ‘(clock_t)(-1)’ to indicate failure.
  1871. *Portability Note:* The ‘clock’ function described in *note CPU
  1872. Time:: is specified by the ISO C standard. The ‘times’ function is a
  1873. feature of POSIX.1. On GNU systems, the CPU time is defined to be
  1874. equivalent to the sum of the ‘tms_utime’ and ‘tms_stime’ fields returned
  1875. by ‘times’.
  1876. 
  1877. File: libc.info, Node: Calendar Time, Next: Setting an Alarm, Prev: Processor And CPU Time, Up: Date and Time
  1878. 21.4 Calendar Time
  1879. ==================
  1880. This section describes facilities for keeping track of calendar time.
  1881. *Note Time Basics::.
  1882. The GNU C Library represents calendar time three ways:
  1883. • "Simple time" (the ‘time_t’ data type) is a compact representation,
  1884. typically giving the number of seconds of elapsed time since some
  1885. implementation-specific base time.
  1886. • There is also a "high-resolution time" representation. Like simple
  1887. time, this represents a calendar time as an elapsed time since a
  1888. base time, but instead of measuring in whole seconds, it uses a
  1889. ‘struct timeval’ data type, which includes fractions of a second.
  1890. Use this time representation instead of simple time when you need
  1891. greater precision.
  1892. • "Local time" or "broken-down time" (the ‘struct tm’ data type)
  1893. represents a calendar time as a set of components specifying the
  1894. year, month, and so on in the Gregorian calendar, for a specific
  1895. time zone. This calendar time representation is usually used only
  1896. to communicate with people.
  1897. * Menu:
  1898. * Simple Calendar Time:: Facilities for manipulating calendar time.
  1899. * High-Resolution Calendar:: A time representation with greater precision.
  1900. * Broken-down Time:: Facilities for manipulating local time.
  1901. * High Accuracy Clock:: Maintaining a high accuracy system clock.
  1902. * Formatting Calendar Time:: Converting times to strings.
  1903. * Parsing Date and Time:: Convert textual time and date information back
  1904. into broken-down time values.
  1905. * TZ Variable:: How users specify the time zone.
  1906. * Time Zone Functions:: Functions to examine or specify the time zone.
  1907. * Time Functions Example:: An example program showing use of some of
  1908. the time functions.
  1909. 
  1910. File: libc.info, Node: Simple Calendar Time, Next: High-Resolution Calendar, Up: Calendar Time
  1911. 21.4.1 Simple Calendar Time
  1912. ---------------------------
  1913. This section describes the ‘time_t’ data type for representing calendar
  1914. time as simple time, and the functions which operate on simple time
  1915. objects. These facilities are declared in the header file ‘time.h’.
  1916. -- Data Type: time_t
  1917. This is the data type used to represent simple time. Sometimes, it
  1918. also represents an elapsed time. When interpreted as a calendar
  1919. time value, it represents the number of seconds elapsed since
  1920. 00:00:00 on January 1, 1970, Coordinated Universal Time. (This
  1921. calendar time is sometimes referred to as the "epoch".) POSIX
  1922. requires that this count not include leap seconds, but on some
  1923. systems this count includes leap seconds if you set ‘TZ’ to certain
  1924. values (*note TZ Variable::).
  1925. Note that a simple time has no concept of local time zone.
  1926. Calendar Time T is the same instant in time regardless of where on
  1927. the globe the computer is.
  1928. In the GNU C Library, ‘time_t’ is equivalent to ‘long int’. In
  1929. other systems, ‘time_t’ might be either an integer or
  1930. floating-point type.
  1931. The function ‘difftime’ tells you the elapsed time between two simple
  1932. calendar times, which is not always as easy to compute as just
  1933. subtracting. *Note Elapsed Time::.
  1934. -- Function: time_t time (time_t *RESULT)
  1935. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1936. Concepts::.
  1937. The ‘time’ function returns the current calendar time as a value of
  1938. type ‘time_t’. If the argument RESULT is not a null pointer, the
  1939. calendar time value is also stored in ‘*RESULT’. If the current
  1940. calendar time is not available, the value ‘(time_t)(-1)’ is
  1941. returned.
  1942. -- Function: int stime (const time_t *NEWTIME)
  1943. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1944. Concepts::.
  1945. ‘stime’ sets the system clock, i.e., it tells the system that the
  1946. current calendar time is NEWTIME, where ‘newtime’ is interpreted as
  1947. described in the above definition of ‘time_t’.
  1948. ‘settimeofday’ is a newer function which sets the system clock to
  1949. better than one second precision. ‘settimeofday’ is generally a
  1950. better choice than ‘stime’. *Note High-Resolution Calendar::.
  1951. Only the superuser can set the system clock.
  1952. If the function succeeds, the return value is zero. Otherwise, it
  1953. is ‘-1’ and ‘errno’ is set accordingly:
  1954. ‘EPERM’
  1955. The process is not superuser.
  1956. 
  1957. File: libc.info, Node: High-Resolution Calendar, Next: Broken-down Time, Prev: Simple Calendar Time, Up: Calendar Time
  1958. 21.4.2 High-Resolution Calendar
  1959. -------------------------------
  1960. The ‘time_t’ data type used to represent simple times has a resolution
  1961. of only one second. Some applications need more precision.
  1962. So, the GNU C Library also contains functions which are capable of
  1963. representing calendar times to a higher resolution than one second. The
  1964. functions and the associated data types described in this section are
  1965. declared in ‘sys/time.h’.
  1966. -- Data Type: struct timezone
  1967. The ‘struct timezone’ structure is used to hold minimal information
  1968. about the local time zone. It has the following members:
  1969. ‘int tz_minuteswest’
  1970. This is the number of minutes west of UTC.
  1971. ‘int tz_dsttime’
  1972. If nonzero, Daylight Saving Time applies during some part of
  1973. the year.
  1974. The ‘struct timezone’ type is obsolete and should never be used.
  1975. Instead, use the facilities described in *note Time Zone
  1976. Functions::.
  1977. -- Function: int gettimeofday (struct timeval *TP, struct timezone
  1978. *TZP)
  1979. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1980. Concepts::.
  1981. The ‘gettimeofday’ function returns the current calendar time as
  1982. the elapsed time since the epoch in the ‘struct timeval’ structure
  1983. indicated by TP. (*note Elapsed Time:: for a description of
  1984. ‘struct timeval’). Information about the time zone is returned in
  1985. the structure pointed to by TZP. If the TZP argument is a null
  1986. pointer, time zone information is ignored.
  1987. The return value is ‘0’ on success and ‘-1’ on failure. The
  1988. following ‘errno’ error condition is defined for this function:
  1989. ‘ENOSYS’
  1990. The operating system does not support getting time zone
  1991. information, and TZP is not a null pointer. GNU systems do
  1992. not support using ‘struct timezone’ to represent time zone
  1993. information; that is an obsolete feature of 4.3 BSD. Instead,
  1994. use the facilities described in *note Time Zone Functions::.
  1995. -- Function: int settimeofday (const struct timeval *TP, const struct
  1996. timezone *TZP)
  1997. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1998. Concepts::.
  1999. The ‘settimeofday’ function sets the current calendar time in the
  2000. system clock according to the arguments. As for ‘gettimeofday’,
  2001. the calendar time is represented as the elapsed time since the
  2002. epoch. As for ‘gettimeofday’, time zone information is ignored if
  2003. TZP is a null pointer.
  2004. You must be a privileged user in order to use ‘settimeofday’.
  2005. Some kernels automatically set the system clock from some source
  2006. such as a hardware clock when they start up. Others, including
  2007. Linux, place the system clock in an “invalid” state (in which
  2008. attempts to read the clock fail). A call of ‘stime’ removes the
  2009. system clock from an invalid state, and system startup scripts
  2010. typically run a program that calls ‘stime’.
  2011. ‘settimeofday’ causes a sudden jump forwards or backwards, which
  2012. can cause a variety of problems in a system. Use ‘adjtime’ (below)
  2013. to make a smooth transition from one time to another by temporarily
  2014. speeding up or slowing down the clock.
  2015. With a Linux kernel, ‘adjtimex’ does the same thing and can also
  2016. make permanent changes to the speed of the system clock so it
  2017. doesn’t need to be corrected as often.
  2018. The return value is ‘0’ on success and ‘-1’ on failure. The
  2019. following ‘errno’ error conditions are defined for this function:
  2020. ‘EPERM’
  2021. This process cannot set the clock because it is not
  2022. privileged.
  2023. ‘ENOSYS’
  2024. The operating system does not support setting time zone
  2025. information, and TZP is not a null pointer.
  2026. -- Function: int adjtime (const struct timeval *DELTA, struct timeval
  2027. *OLDDELTA)
  2028. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2029. Concepts::.
  2030. This function speeds up or slows down the system clock in order to
  2031. make a gradual adjustment. This ensures that the calendar time
  2032. reported by the system clock is always monotonically increasing,
  2033. which might not happen if you simply set the clock.
  2034. The DELTA argument specifies a relative adjustment to be made to
  2035. the clock time. If negative, the system clock is slowed down for a
  2036. while until it has lost this much elapsed time. If positive, the
  2037. system clock is speeded up for a while.
  2038. If the OLDDELTA argument is not a null pointer, the ‘adjtime’
  2039. function returns information about any previous time adjustment
  2040. that has not yet completed.
  2041. This function is typically used to synchronize the clocks of
  2042. computers in a local network. You must be a privileged user to use
  2043. it.
  2044. With a Linux kernel, you can use the ‘adjtimex’ function to
  2045. permanently change the clock speed.
  2046. The return value is ‘0’ on success and ‘-1’ on failure. The
  2047. following ‘errno’ error condition is defined for this function:
  2048. ‘EPERM’
  2049. You do not have privilege to set the time.
  2050. *Portability Note:* The ‘gettimeofday’, ‘settimeofday’, and ‘adjtime’
  2051. functions are derived from BSD.
  2052. Symbols for the following function are declared in ‘sys/timex.h’.
  2053. -- Function: int adjtimex (struct timex *TIMEX)
  2054. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2055. Concepts::.
  2056. ‘adjtimex’ is functionally identical to ‘ntp_adjtime’. *Note High
  2057. Accuracy Clock::.
  2058. This function is present only with a Linux kernel.
  2059. 
  2060. File: libc.info, Node: Broken-down Time, Next: High Accuracy Clock, Prev: High-Resolution Calendar, Up: Calendar Time
  2061. 21.4.3 Broken-down Time
  2062. -----------------------
  2063. Calendar time is represented by the usual GNU C Library functions as an
  2064. elapsed time since a fixed base calendar time. This is convenient for
  2065. computation, but has no relation to the way people normally think of
  2066. calendar time. By contrast, "broken-down time" is a binary
  2067. representation of calendar time separated into year, month, day, and so
  2068. on. Broken-down time values are not useful for calculations, but they
  2069. are useful for printing human readable time information.
  2070. A broken-down time value is always relative to a choice of time zone,
  2071. and it also indicates which time zone that is.
  2072. The symbols in this section are declared in the header file ‘time.h’.
  2073. -- Data Type: struct tm
  2074. This is the data type used to represent a broken-down time. The
  2075. structure contains at least the following members, which can appear
  2076. in any order.
  2077. ‘int tm_sec’
  2078. This is the number of full seconds since the top of the minute
  2079. (normally in the range ‘0’ through ‘59’, but the actual upper
  2080. limit is ‘60’, to allow for leap seconds if leap second
  2081. support is available).
  2082. ‘int tm_min’
  2083. This is the number of full minutes since the top of the hour
  2084. (in the range ‘0’ through ‘59’).
  2085. ‘int tm_hour’
  2086. This is the number of full hours past midnight (in the range
  2087. ‘0’ through ‘23’).
  2088. ‘int tm_mday’
  2089. This is the ordinal day of the month (in the range ‘1’ through
  2090. ‘31’). Watch out for this one! As the only ordinal number in
  2091. the structure, it is inconsistent with the rest of the
  2092. structure.
  2093. ‘int tm_mon’
  2094. This is the number of full calendar months since the beginning
  2095. of the year (in the range ‘0’ through ‘11’). Watch out for
  2096. this one! People usually use ordinal numbers for
  2097. month-of-year (where January = 1).
  2098. ‘int tm_year’
  2099. This is the number of full calendar years since 1900.
  2100. ‘int tm_wday’
  2101. This is the number of full days since Sunday (in the range ‘0’
  2102. through ‘6’).
  2103. ‘int tm_yday’
  2104. This is the number of full days since the beginning of the
  2105. year (in the range ‘0’ through ‘365’).
  2106. ‘int tm_isdst’
  2107. This is a flag that indicates whether Daylight Saving Time is
  2108. (or was, or will be) in effect at the time described. The
  2109. value is positive if Daylight Saving Time is in effect, zero
  2110. if it is not, and negative if the information is not
  2111. available.
  2112. ‘long int tm_gmtoff’
  2113. This field describes the time zone that was used to compute
  2114. this broken-down time value, including any adjustment for
  2115. daylight saving; it is the number of seconds that you must add
  2116. to UTC to get local time. You can also think of this as the
  2117. number of seconds east of UTC. For example, for U.S. Eastern
  2118. Standard Time, the value is ‘-5*60*60’. The ‘tm_gmtoff’ field
  2119. is derived from BSD and is a GNU library extension; it is not
  2120. visible in a strict ISO C environment.
  2121. ‘const char *tm_zone’
  2122. This field is the name for the time zone that was used to
  2123. compute this broken-down time value. Like ‘tm_gmtoff’, this
  2124. field is a BSD and GNU extension, and is not visible in a
  2125. strict ISO C environment.
  2126. -- Function: struct tm * localtime (const time_t *TIME)
  2127. Preliminary: | MT-Unsafe race:tmbuf env locale | AS-Unsafe heap
  2128. lock | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  2129. The ‘localtime’ function converts the simple time pointed to by
  2130. TIME to broken-down time representation, expressed relative to the
  2131. user’s specified time zone.
  2132. The return value is a pointer to a static broken-down time
  2133. structure, which might be overwritten by subsequent calls to
  2134. ‘ctime’, ‘gmtime’, or ‘localtime’. (But no other library function
  2135. overwrites the contents of this object.)
  2136. The return value is the null pointer if TIME cannot be represented
  2137. as a broken-down time; typically this is because the year cannot
  2138. fit into an ‘int’.
  2139. Calling ‘localtime’ also sets the current time zone as if ‘tzset’
  2140. were called. *Note Time Zone Functions::.
  2141. Using the ‘localtime’ function is a big problem in multi-threaded
  2142. programs. The result is returned in a static buffer and this is used in
  2143. all threads. POSIX.1c introduced a variant of this function.
  2144. -- Function: struct tm * localtime_r (const time_t *TIME, struct tm
  2145. *RESULTP)
  2146. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2147. lock mem fd | *Note POSIX Safety Concepts::.
  2148. The ‘localtime_r’ function works just like the ‘localtime’
  2149. function. It takes a pointer to a variable containing a simple
  2150. time and converts it to the broken-down time format.
  2151. But the result is not placed in a static buffer. Instead it is
  2152. placed in the object of type ‘struct tm’ to which the parameter
  2153. RESULTP points.
  2154. If the conversion is successful the function returns a pointer to
  2155. the object the result was written into, i.e., it returns RESULTP.
  2156. -- Function: struct tm * gmtime (const time_t *TIME)
  2157. Preliminary: | MT-Unsafe race:tmbuf env locale | AS-Unsafe heap
  2158. lock | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  2159. This function is similar to ‘localtime’, except that the
  2160. broken-down time is expressed as Coordinated Universal Time (UTC)
  2161. (formerly called Greenwich Mean Time (GMT)) rather than relative to
  2162. a local time zone.
  2163. As for the ‘localtime’ function we have the problem that the result
  2164. is placed in a static variable. POSIX.1c also provides a replacement
  2165. for ‘gmtime’.
  2166. -- Function: struct tm * gmtime_r (const time_t *TIME, struct tm
  2167. *RESULTP)
  2168. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2169. lock mem fd | *Note POSIX Safety Concepts::.
  2170. This function is similar to ‘localtime_r’, except that it converts
  2171. just like ‘gmtime’ the given time as Coordinated Universal Time.
  2172. If the conversion is successful the function returns a pointer to
  2173. the object the result was written into, i.e., it returns RESULTP.
  2174. -- Function: time_t mktime (struct tm *BROKENTIME)
  2175. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2176. lock mem fd | *Note POSIX Safety Concepts::.
  2177. The ‘mktime’ function converts a broken-down time structure to a
  2178. simple time representation. It also normalizes the contents of the
  2179. broken-down time structure, and fills in some components based on
  2180. the values of the others.
  2181. The ‘mktime’ function ignores the specified contents of the
  2182. ‘tm_wday’, ‘tm_yday’, ‘tm_gmtoff’, and ‘tm_zone’ members of the
  2183. broken-down time structure. It uses the values of the other
  2184. components to determine the calendar time; it’s permissible for
  2185. these components to have unnormalized values outside their normal
  2186. ranges. The last thing that ‘mktime’ does is adjust the components
  2187. of the BROKENTIME structure, including the members that were
  2188. initially ignored.
  2189. If the specified broken-down time cannot be represented as a simple
  2190. time, ‘mktime’ returns a value of ‘(time_t)(-1)’ and does not
  2191. modify the contents of BROKENTIME.
  2192. Calling ‘mktime’ also sets the current time zone as if ‘tzset’ were
  2193. called; ‘mktime’ uses this information instead of BROKENTIME’s
  2194. initial ‘tm_gmtoff’ and ‘tm_zone’ members. *Note Time Zone
  2195. Functions::.
  2196. -- Function: time_t timelocal (struct tm *BROKENTIME)
  2197. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2198. lock mem fd | *Note POSIX Safety Concepts::.
  2199. ‘timelocal’ is functionally identical to ‘mktime’, but more
  2200. mnemonically named. Note that it is the inverse of the ‘localtime’
  2201. function.
  2202. *Portability note:* ‘mktime’ is essentially universally available.
  2203. ‘timelocal’ is rather rare.
  2204. -- Function: time_t timegm (struct tm *BROKENTIME)
  2205. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2206. lock mem fd | *Note POSIX Safety Concepts::.
  2207. ‘timegm’ is functionally identical to ‘mktime’ except it always
  2208. takes the input values to be Coordinated Universal Time (UTC)
  2209. regardless of any local time zone setting.
  2210. Note that ‘timegm’ is the inverse of ‘gmtime’.
  2211. *Portability note:* ‘mktime’ is essentially universally available.
  2212. ‘timegm’ is rather rare. For the most portable conversion from a
  2213. UTC broken-down time to a simple time, set the ‘TZ’ environment
  2214. variable to UTC, call ‘mktime’, then set ‘TZ’ back.
  2215. 
  2216. File: libc.info, Node: High Accuracy Clock, Next: Formatting Calendar Time, Prev: Broken-down Time, Up: Calendar Time
  2217. 21.4.4 High Accuracy Clock
  2218. --------------------------
  2219. The ‘ntp_gettime’ and ‘ntp_adjtime’ functions provide an interface to
  2220. monitor and manipulate the system clock to maintain high accuracy time.
  2221. For example, you can fine tune the speed of the clock or synchronize it
  2222. with another time source.
  2223. A typical use of these functions is by a server implementing the
  2224. Network Time Protocol to synchronize the clocks of multiple systems and
  2225. high precision clocks.
  2226. These functions are declared in ‘sys/timex.h’.
  2227. -- Data Type: struct ntptimeval
  2228. This structure is used for information about the system clock. It
  2229. contains the following members:
  2230. ‘struct timeval time’
  2231. This is the current calendar time, expressed as the elapsed
  2232. time since the epoch. The ‘struct timeval’ data type is
  2233. described in *note Elapsed Time::.
  2234. ‘long int maxerror’
  2235. This is the maximum error, measured in microseconds. Unless
  2236. updated via ‘ntp_adjtime’ periodically, this value will reach
  2237. some platform-specific maximum value.
  2238. ‘long int esterror’
  2239. This is the estimated error, measured in microseconds. This
  2240. value can be set by ‘ntp_adjtime’ to indicate the estimated
  2241. offset of the system clock from the true calendar time.
  2242. -- Function: int ntp_gettime (struct ntptimeval *TPTR)
  2243. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2244. Concepts::.
  2245. The ‘ntp_gettime’ function sets the structure pointed to by TPTR to
  2246. current values. The elements of the structure afterwards contain
  2247. the values the timer implementation in the kernel assumes. They
  2248. might or might not be correct. If they are not, an ‘ntp_adjtime’
  2249. call is necessary.
  2250. The return value is ‘0’ on success and other values on failure.
  2251. The following ‘errno’ error conditions are defined for this
  2252. function:
  2253. ‘TIME_ERROR’
  2254. The precision clock model is not properly set up at the
  2255. moment, thus the clock must be considered unsynchronized, and
  2256. the values should be treated with care.
  2257. -- Data Type: struct timex
  2258. This structure is used to control and monitor the system clock. It
  2259. contains the following members:
  2260. ‘unsigned int modes’
  2261. This variable controls whether and which values are set.
  2262. Several symbolic constants have to be combined with _binary
  2263. or_ to specify the effective mode. These constants start with
  2264. ‘MOD_’.
  2265. ‘long int offset’
  2266. This value indicates the current offset of the system clock
  2267. from the true calendar time. The value is given in
  2268. microseconds. If bit ‘MOD_OFFSET’ is set in ‘modes’, the
  2269. offset (and possibly other dependent values) can be set. The
  2270. offset’s absolute value must not exceed ‘MAXPHASE’.
  2271. ‘long int frequency’
  2272. This value indicates the difference in frequency between the
  2273. true calendar time and the system clock. The value is
  2274. expressed as scaled PPM (parts per million, 0.0001%). The
  2275. scaling is ‘1 << SHIFT_USEC’. The value can be set with bit
  2276. ‘MOD_FREQUENCY’, but the absolute value must not exceed
  2277. ‘MAXFREQ’.
  2278. ‘long int maxerror’
  2279. This is the maximum error, measured in microseconds. A new
  2280. value can be set using bit ‘MOD_MAXERROR’. Unless updated via
  2281. ‘ntp_adjtime’ periodically, this value will increase steadily
  2282. and reach some platform-specific maximum value.
  2283. ‘long int esterror’
  2284. This is the estimated error, measured in microseconds. This
  2285. value can be set using bit ‘MOD_ESTERROR’.
  2286. ‘int status’
  2287. This variable reflects the various states of the clock
  2288. machinery. There are symbolic constants for the significant
  2289. bits, starting with ‘STA_’. Some of these flags can be
  2290. updated using the ‘MOD_STATUS’ bit.
  2291. ‘long int constant’
  2292. This value represents the bandwidth or stiffness of the PLL
  2293. (phase locked loop) implemented in the kernel. The value can
  2294. be changed using bit ‘MOD_TIMECONST’.
  2295. ‘long int precision’
  2296. This value represents the accuracy or the maximum error when
  2297. reading the system clock. The value is expressed in
  2298. microseconds.
  2299. ‘long int tolerance’
  2300. This value represents the maximum frequency error of the
  2301. system clock in scaled PPM. This value is used to increase the
  2302. ‘maxerror’ every second.
  2303. ‘struct timeval time’
  2304. The current calendar time.
  2305. ‘long int tick’
  2306. The elapsed time between clock ticks in microseconds. A clock
  2307. tick is a periodic timer interrupt on which the system clock
  2308. is based.
  2309. ‘long int ppsfreq’
  2310. This is the first of a few optional variables that are present
  2311. only if the system clock can use a PPS (pulse per second)
  2312. signal to discipline the system clock. The value is expressed
  2313. in scaled PPM and it denotes the difference in frequency
  2314. between the system clock and the PPS signal.
  2315. ‘long int jitter’
  2316. This value expresses a median filtered average of the PPS
  2317. signal’s dispersion in microseconds.
  2318. ‘int shift’
  2319. This value is a binary exponent for the duration of the PPS
  2320. calibration interval, ranging from ‘PPS_SHIFT’ to
  2321. ‘PPS_SHIFTMAX’.
  2322. ‘long int stabil’
  2323. This value represents the median filtered dispersion of the
  2324. PPS frequency in scaled PPM.
  2325. ‘long int jitcnt’
  2326. This counter represents the number of pulses where the jitter
  2327. exceeded the allowed maximum ‘MAXTIME’.
  2328. ‘long int calcnt’
  2329. This counter reflects the number of successful calibration
  2330. intervals.
  2331. ‘long int errcnt’
  2332. This counter represents the number of calibration errors
  2333. (caused by large offsets or jitter).
  2334. ‘long int stbcnt’
  2335. This counter denotes the number of calibrations where the
  2336. stability exceeded the threshold.
  2337. -- Function: int ntp_adjtime (struct timex *TPTR)
  2338. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2339. Concepts::.
  2340. The ‘ntp_adjtime’ function sets the structure specified by TPTR to
  2341. current values.
  2342. In addition, ‘ntp_adjtime’ updates some settings to match what you
  2343. pass to it in *TPTR. Use the ‘modes’ element of *TPTR to select
  2344. what settings to update. You can set ‘offset’, ‘freq’, ‘maxerror’,
  2345. ‘esterror’, ‘status’, ‘constant’, and ‘tick’.
  2346. ‘modes’ = zero means set nothing.
  2347. Only the superuser can update settings.
  2348. The return value is ‘0’ on success and other values on failure.
  2349. The following ‘errno’ error conditions are defined for this
  2350. function:
  2351. ‘TIME_ERROR’
  2352. The high accuracy clock model is not properly set up at the
  2353. moment, thus the clock must be considered unsynchronized, and
  2354. the values should be treated with care. Another reason could
  2355. be that the specified new values are not allowed.
  2356. ‘EPERM’
  2357. The process specified a settings update, but is not superuser.
  2358. For more details see RFC1305 (Network Time Protocol, Version 3) and
  2359. related documents.
  2360. *Portability note:* Early versions of the GNU C Library did not
  2361. have this function but did have the synonymous ‘adjtimex’.
  2362. 
  2363. File: libc.info, Node: Formatting Calendar Time, Next: Parsing Date and Time, Prev: High Accuracy Clock, Up: Calendar Time
  2364. 21.4.5 Formatting Calendar Time
  2365. -------------------------------
  2366. The functions described in this section format calendar time values as
  2367. strings. These functions are declared in the header file ‘time.h’.
  2368. -- Function: char * asctime (const struct tm *BROKENTIME)
  2369. Preliminary: | MT-Unsafe race:asctime locale | AS-Unsafe | AC-Safe
  2370. | *Note POSIX Safety Concepts::.
  2371. The ‘asctime’ function converts the broken-down time value that
  2372. BROKENTIME points to into a string in a standard format:
  2373. "Tue May 21 13:46:22 1991\n"
  2374. The abbreviations for the days of week are: ‘Sun’, ‘Mon’, ‘Tue’,
  2375. ‘Wed’, ‘Thu’, ‘Fri’, and ‘Sat’.
  2376. The abbreviations for the months are: ‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’,
  2377. ‘May’, ‘Jun’, ‘Jul’, ‘Aug’, ‘Sep’, ‘Oct’, ‘Nov’, and ‘Dec’.
  2378. The return value points to a statically allocated string, which
  2379. might be overwritten by subsequent calls to ‘asctime’ or ‘ctime’.
  2380. (But no other library function overwrites the contents of this
  2381. string.)
  2382. -- Function: char * asctime_r (const struct tm *BROKENTIME, char
  2383. *BUFFER)
  2384. Preliminary: | MT-Safe locale | AS-Safe | AC-Safe | *Note POSIX
  2385. Safety Concepts::.
  2386. This function is similar to ‘asctime’ but instead of placing the
  2387. result in a static buffer it writes the string in the buffer
  2388. pointed to by the parameter BUFFER. This buffer should have room
  2389. for at least 26 bytes, including the terminating null.
  2390. If no error occurred the function returns a pointer to the string
  2391. the result was written into, i.e., it returns BUFFER. Otherwise it
  2392. returns ‘NULL’.
  2393. -- Function: char * ctime (const time_t *TIME)
  2394. Preliminary: | MT-Unsafe race:tmbuf race:asctime env locale |
  2395. AS-Unsafe heap lock | AC-Unsafe lock mem fd | *Note POSIX Safety
  2396. Concepts::.
  2397. The ‘ctime’ function is similar to ‘asctime’, except that you
  2398. specify the calendar time argument as a ‘time_t’ simple time value
  2399. rather than in broken-down local time format. It is equivalent to
  2400. asctime (localtime (TIME))
  2401. Calling ‘ctime’ also sets the current time zone as if ‘tzset’ were
  2402. called. *Note Time Zone Functions::.
  2403. -- Function: char * ctime_r (const time_t *TIME, char *BUFFER)
  2404. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2405. lock mem fd | *Note POSIX Safety Concepts::.
  2406. This function is similar to ‘ctime’, but places the result in the
  2407. string pointed to by BUFFER. It is equivalent to (written using
  2408. gcc extensions, *note (gcc)Statement Exprs::):
  2409. ({ struct tm tm; asctime_r (localtime_r (time, &tm), buf); })
  2410. If no error occurred the function returns a pointer to the string
  2411. the result was written into, i.e., it returns BUFFER. Otherwise it
  2412. returns ‘NULL’.
  2413. -- Function: size_t strftime (char *S, size_t SIZE, const char
  2414. *TEMPLATE, const struct tm *BROKENTIME)
  2415. Preliminary: | MT-Safe env locale | AS-Unsafe corrupt heap lock
  2416. dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety
  2417. Concepts::.
  2418. This function is similar to the ‘sprintf’ function (*note Formatted
  2419. Input::), but the conversion specifications that can appear in the
  2420. format template TEMPLATE are specialized for printing components of
  2421. the date and time BROKENTIME according to the locale currently
  2422. specified for time conversion (*note Locales::) and the current
  2423. time zone (*note Time Zone Functions::).
  2424. Ordinary characters appearing in the TEMPLATE are copied to the
  2425. output string S; this can include multibyte character sequences.
  2426. Conversion specifiers are introduced by a ‘%’ character, followed
  2427. by an optional flag which can be one of the following. These flags
  2428. are all GNU extensions. The first three affect only the output of
  2429. numbers:
  2430. ‘_’
  2431. The number is padded with spaces.
  2432. ‘-’
  2433. The number is not padded at all.
  2434. ‘0’
  2435. The number is padded with zeros even if the format specifies
  2436. padding with spaces.
  2437. ‘^’
  2438. The output uses uppercase characters, but only if this is
  2439. possible (*note Case Conversion::).
  2440. The default action is to pad the number with zeros to keep it a
  2441. constant width. Numbers that do not have a range indicated below
  2442. are never padded, since there is no natural width for them.
  2443. Following the flag an optional specification of the width is
  2444. possible. This is specified in decimal notation. If the natural
  2445. size of the output of the field has less than the specified number
  2446. of characters, the result is written right adjusted and space
  2447. padded to the given size.
  2448. An optional modifier can follow the optional flag and width
  2449. specification. The modifiers, which were first standardized by
  2450. POSIX.2-1992 and by ISO C99, are:
  2451. ‘E’
  2452. Use the locale’s alternate representation for date and time.
  2453. This modifier applies to the ‘%c’, ‘%C’, ‘%x’, ‘%X’, ‘%y’ and
  2454. ‘%Y’ format specifiers. In a Japanese locale, for example,
  2455. ‘%Ex’ might yield a date format based on the Japanese
  2456. Emperors’ reigns.
  2457. ‘O’
  2458. Use the locale’s alternate numeric symbols for numbers. This
  2459. modifier applies only to numeric format specifiers.
  2460. If the format supports the modifier but no alternate representation
  2461. is available, it is ignored.
  2462. The conversion specifier ends with a format specifier taken from
  2463. the following list. The whole ‘%’ sequence is replaced in the
  2464. output string as follows:
  2465. ‘%a’
  2466. The abbreviated weekday name according to the current locale.
  2467. ‘%A’
  2468. The full weekday name according to the current locale.
  2469. ‘%b’
  2470. The abbreviated month name according to the current locale.
  2471. ‘%B’
  2472. The full month name according to the current locale.
  2473. Using ‘%B’ together with ‘%d’ produces grammatically incorrect
  2474. results for some locales.
  2475. ‘%c’
  2476. The preferred calendar time representation for the current
  2477. locale.
  2478. ‘%C’
  2479. The century of the year. This is equivalent to the greatest
  2480. integer not greater than the year divided by 100.
  2481. This format was first standardized by POSIX.2-1992 and by
  2482. ISO C99.
  2483. ‘%d’
  2484. The day of the month as a decimal number (range ‘01’ through
  2485. ‘31’).
  2486. ‘%D’
  2487. The date using the format ‘%m/%d/%y’.
  2488. This format was first standardized by POSIX.2-1992 and by
  2489. ISO C99.
  2490. ‘%e’
  2491. The day of the month like with ‘%d’, but padded with spaces
  2492. (range ‘ 1’ through ‘31’).
  2493. This format was first standardized by POSIX.2-1992 and by
  2494. ISO C99.
  2495. ‘%F’
  2496. The date using the format ‘%Y-%m-%d’. This is the form
  2497. specified in the ISO 8601 standard and is the preferred form
  2498. for all uses.
  2499. This format was first standardized by ISO C99 and by
  2500. POSIX.1-2001.
  2501. ‘%g’
  2502. The year corresponding to the ISO week number, but without the
  2503. century (range ‘00’ through ‘99’). This has the same format
  2504. and value as ‘%y’, except that if the ISO week number (see
  2505. ‘%V’) belongs to the previous or next year, that year is used
  2506. instead.
  2507. This format was first standardized by ISO C99 and by
  2508. POSIX.1-2001.
  2509. ‘%G’
  2510. The year corresponding to the ISO week number. This has the
  2511. same format and value as ‘%Y’, except that if the ISO week
  2512. number (see ‘%V’) belongs to the previous or next year, that
  2513. year is used instead.
  2514. This format was first standardized by ISO C99 and by
  2515. POSIX.1-2001 but was previously available as a GNU extension.
  2516. ‘%h’
  2517. The abbreviated month name according to the current locale.
  2518. The action is the same as for ‘%b’.
  2519. This format was first standardized by POSIX.2-1992 and by
  2520. ISO C99.
  2521. ‘%H’
  2522. The hour as a decimal number, using a 24-hour clock (range
  2523. ‘00’ through ‘23’).
  2524. ‘%I’
  2525. The hour as a decimal number, using a 12-hour clock (range
  2526. ‘01’ through ‘12’).
  2527. ‘%j’
  2528. The day of the year as a decimal number (range ‘001’ through
  2529. ‘366’).
  2530. ‘%k’
  2531. The hour as a decimal number, using a 24-hour clock like ‘%H’,
  2532. but padded with spaces (range ‘ 0’ through ‘23’).
  2533. This format is a GNU extension.
  2534. ‘%l’
  2535. The hour as a decimal number, using a 12-hour clock like ‘%I’,
  2536. but padded with spaces (range ‘ 1’ through ‘12’).
  2537. This format is a GNU extension.
  2538. ‘%m’
  2539. The month as a decimal number (range ‘01’ through ‘12’).
  2540. ‘%M’
  2541. The minute as a decimal number (range ‘00’ through ‘59’).
  2542. ‘%n’
  2543. A single ‘\n’ (newline) character.
  2544. This format was first standardized by POSIX.2-1992 and by
  2545. ISO C99.
  2546. ‘%p’
  2547. Either ‘AM’ or ‘PM’, according to the given time value; or the
  2548. corresponding strings for the current locale. Noon is treated
  2549. as ‘PM’ and midnight as ‘AM’. In most locales ‘AM’/‘PM’
  2550. format is not supported, in such cases ‘"%p"’ yields an empty
  2551. string.
  2552. ‘%P’
  2553. Either ‘am’ or ‘pm’, according to the given time value; or the
  2554. corresponding strings for the current locale, printed in
  2555. lowercase characters. Noon is treated as ‘pm’ and midnight as
  2556. ‘am’. In most locales ‘AM’/‘PM’ format is not supported, in
  2557. such cases ‘"%P"’ yields an empty string.
  2558. This format is a GNU extension.
  2559. ‘%r’
  2560. The complete calendar time using the AM/PM format of the
  2561. current locale.
  2562. This format was first standardized by POSIX.2-1992 and by
  2563. ISO C99. In the POSIX locale, this format is equivalent to
  2564. ‘%I:%M:%S %p’.
  2565. ‘%R’
  2566. The hour and minute in decimal numbers using the format
  2567. ‘%H:%M’.
  2568. This format was first standardized by ISO C99 and by
  2569. POSIX.1-2001 but was previously available as a GNU extension.
  2570. ‘%s’
  2571. The number of seconds since the epoch, i.e., since 1970-01-01
  2572. 00:00:00 UTC. Leap seconds are not counted unless leap second
  2573. support is available.
  2574. This format is a GNU extension.
  2575. ‘%S’
  2576. The seconds as a decimal number (range ‘00’ through ‘60’).
  2577. ‘%t’
  2578. A single ‘\t’ (tabulator) character.
  2579. This format was first standardized by POSIX.2-1992 and by
  2580. ISO C99.
  2581. ‘%T’
  2582. The time of day using decimal numbers using the format
  2583. ‘%H:%M:%S’.
  2584. This format was first standardized by POSIX.2-1992 and by
  2585. ISO C99.
  2586. ‘%u’
  2587. The day of the week as a decimal number (range ‘1’ through
  2588. ‘7’), Monday being ‘1’.
  2589. This format was first standardized by POSIX.2-1992 and by
  2590. ISO C99.
  2591. ‘%U’
  2592. The week number of the current year as a decimal number (range
  2593. ‘00’ through ‘53’), starting with the first Sunday as the
  2594. first day of the first week. Days preceding the first Sunday
  2595. in the year are considered to be in week ‘00’.
  2596. ‘%V’
  2597. The ISO 8601:1988 week number as a decimal number (range ‘01’
  2598. through ‘53’). ISO weeks start with Monday and end with
  2599. Sunday. Week ‘01’ of a year is the first week which has the
  2600. majority of its days in that year; this is equivalent to the
  2601. week containing the year’s first Thursday, and it is also
  2602. equivalent to the week containing January 4. Week ‘01’ of a
  2603. year can contain days from the previous year. The week before
  2604. week ‘01’ of a year is the last week (‘52’ or ‘53’) of the
  2605. previous year even if it contains days from the new year.
  2606. This format was first standardized by POSIX.2-1992 and by
  2607. ISO C99.
  2608. ‘%w’
  2609. The day of the week as a decimal number (range ‘0’ through
  2610. ‘6’), Sunday being ‘0’.
  2611. ‘%W’
  2612. The week number of the current year as a decimal number (range
  2613. ‘00’ through ‘53’), starting with the first Monday as the
  2614. first day of the first week. All days preceding the first
  2615. Monday in the year are considered to be in week ‘00’.
  2616. ‘%x’
  2617. The preferred date representation for the current locale.
  2618. ‘%X’
  2619. The preferred time of day representation for the current
  2620. locale.
  2621. ‘%y’
  2622. The year without a century as a decimal number (range ‘00’
  2623. through ‘99’). This is equivalent to the year modulo 100.
  2624. ‘%Y’
  2625. The year as a decimal number, using the Gregorian calendar.
  2626. Years before the year ‘1’ are numbered ‘0’, ‘-1’, and so on.
  2627. ‘%z’
  2628. RFC 822/ISO 8601:1988 style numeric time zone (e.g., ‘-0600’
  2629. or ‘+0100’), or nothing if no time zone is determinable.
  2630. This format was first standardized by ISO C99 and by
  2631. POSIX.1-2001 but was previously available as a GNU extension.
  2632. In the POSIX locale, a full RFC 822 timestamp is generated by
  2633. the format ‘"%a, %d %b %Y %H:%M:%S %z"’ (or the equivalent
  2634. ‘"%a, %d %b %Y %T %z"’).
  2635. ‘%Z’
  2636. The time zone abbreviation (empty if the time zone can’t be
  2637. determined).
  2638. ‘%%’
  2639. A literal ‘%’ character.
  2640. The SIZE parameter can be used to specify the maximum number of
  2641. characters to be stored in the array S, including the terminating
  2642. null character. If the formatted time requires more than SIZE
  2643. characters, ‘strftime’ returns zero and the contents of the array S
  2644. are undefined. Otherwise the return value indicates the number of
  2645. characters placed in the array S, not including the terminating
  2646. null character.
  2647. _Warning:_ This convention for the return value which is prescribed
  2648. in ISO C can lead to problems in some situations. For certain
  2649. format strings and certain locales the output really can be the
  2650. empty string and this cannot be discovered by testing the return
  2651. value only. E.g., in most locales the AM/PM time format is not
  2652. supported (most of the world uses the 24 hour time representation).
  2653. In such locales ‘"%p"’ will return the empty string, i.e., the
  2654. return value is zero. To detect situations like this something
  2655. similar to the following code should be used:
  2656. buf[0] = '\1';
  2657. len = strftime (buf, bufsize, format, tp);
  2658. if (len == 0 && buf[0] != '\0')
  2659. {
  2660. /* Something went wrong in the strftime call. */
  2661. }
  2662. If S is a null pointer, ‘strftime’ does not actually write
  2663. anything, but instead returns the number of characters it would
  2664. have written.
  2665. Calling ‘strftime’ also sets the current time zone as if ‘tzset’
  2666. were called; ‘strftime’ uses this information instead of
  2667. BROKENTIME’s ‘tm_gmtoff’ and ‘tm_zone’ members. *Note Time Zone
  2668. Functions::.
  2669. For an example of ‘strftime’, see *note Time Functions Example::.
  2670. -- Function: size_t wcsftime (wchar_t *S, size_t SIZE, const wchar_t
  2671. *TEMPLATE, const struct tm *BROKENTIME)
  2672. Preliminary: | MT-Safe env locale | AS-Unsafe corrupt heap lock
  2673. dlopen | AC-Unsafe corrupt lock mem fd | *Note POSIX Safety
  2674. Concepts::.
  2675. The ‘wcsftime’ function is equivalent to the ‘strftime’ function
  2676. with the difference that it operates on wide character strings.
  2677. The buffer where the result is stored, pointed to by S, must be an
  2678. array of wide characters. The parameter SIZE which specifies the
  2679. size of the output buffer gives the number of wide characters, not
  2680. the number of bytes.
  2681. Also the format string TEMPLATE is a wide character string. Since
  2682. all characters needed to specify the format string are in the basic
  2683. character set it is portably possible to write format strings in
  2684. the C source code using the ‘L"…"’ notation. The parameter
  2685. BROKENTIME has the same meaning as in the ‘strftime’ call.
  2686. The ‘wcsftime’ function supports the same flags, modifiers, and
  2687. format specifiers as the ‘strftime’ function.
  2688. The return value of ‘wcsftime’ is the number of wide characters
  2689. stored in ‘s’. When more characters would have to be written than
  2690. can be placed in the buffer S the return value is zero, with the
  2691. same problems indicated in the ‘strftime’ documentation.
  2692. 
  2693. File: libc.info, Node: Parsing Date and Time, Next: TZ Variable, Prev: Formatting Calendar Time, Up: Calendar Time
  2694. 21.4.6 Convert textual time and date information back
  2695. -----------------------------------------------------
  2696. The ISO C standard does not specify any functions which can convert the
  2697. output of the ‘strftime’ function back into a binary format. This led
  2698. to a variety of more-or-less successful implementations with different
  2699. interfaces over the years. Then the Unix standard was extended by the
  2700. addition of two functions: ‘strptime’ and ‘getdate’. Both have strange
  2701. interfaces but at least they are widely available.
  2702. * Menu:
  2703. * Low-Level Time String Parsing:: Interpret string according to given format.
  2704. * General Time String Parsing:: User-friendly function to parse data and
  2705. time strings.
  2706. 
  2707. File: libc.info, Node: Low-Level Time String Parsing, Next: General Time String Parsing, Up: Parsing Date and Time
  2708. 21.4.6.1 Interpret string according to given format
  2709. ...................................................
  2710. The first function is rather low-level. It is nevertheless frequently
  2711. used in software since it is better known. Its interface and
  2712. implementation are heavily influenced by the ‘getdate’ function, which
  2713. is defined and implemented in terms of calls to ‘strptime’.
  2714. -- Function: char * strptime (const char *S, const char *FMT, struct tm
  2715. *TP)
  2716. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  2717. lock mem fd | *Note POSIX Safety Concepts::.
  2718. The ‘strptime’ function parses the input string S according to the
  2719. format string FMT and stores its results in the structure TP.
  2720. The input string could be generated by a ‘strftime’ call or
  2721. obtained any other way. It does not need to be in a
  2722. human-recognizable format; e.g. a date passed as ‘"02:1999:9"’ is
  2723. acceptable, even though it is ambiguous without context. As long
  2724. as the format string FMT matches the input string the function will
  2725. succeed.
  2726. The user has to make sure, though, that the input can be parsed in
  2727. a unambiguous way. The string ‘"1999112"’ can be parsed using the
  2728. format ‘"%Y%m%d"’ as 1999-1-12, 1999-11-2, or even 19991-1-2. It
  2729. is necessary to add appropriate separators to reliably get results.
  2730. The format string consists of the same components as the format
  2731. string of the ‘strftime’ function. The only difference is that the
  2732. flags ‘_’, ‘-’, ‘0’, and ‘^’ are not allowed. Several of the
  2733. distinct formats of ‘strftime’ do the same work in ‘strptime’ since
  2734. differences like case of the input do not matter. For reasons of
  2735. symmetry all formats are supported, though.
  2736. The modifiers ‘E’ and ‘O’ are also allowed everywhere the
  2737. ‘strftime’ function allows them.
  2738. The formats are:
  2739. ‘%a’
  2740. ‘%A’
  2741. The weekday name according to the current locale, in
  2742. abbreviated form or the full name.
  2743. ‘%b’
  2744. ‘%B’
  2745. ‘%h’
  2746. The month name according to the current locale, in abbreviated
  2747. form or the full name.
  2748. ‘%c’
  2749. The date and time representation for the current locale.
  2750. ‘%Ec’
  2751. Like ‘%c’ but the locale’s alternative date and time format is
  2752. used.
  2753. ‘%C’
  2754. The century of the year.
  2755. It makes sense to use this format only if the format string
  2756. also contains the ‘%y’ format.
  2757. ‘%EC’
  2758. The locale’s representation of the period.
  2759. Unlike ‘%C’ it sometimes makes sense to use this format since
  2760. some cultures represent years relative to the beginning of
  2761. eras instead of using the Gregorian years.
  2762. ‘%d’
  2763. ‘%e’
  2764. The day of the month as a decimal number (range ‘1’ through
  2765. ‘31’). Leading zeroes are permitted but not required.
  2766. ‘%Od’
  2767. ‘%Oe’
  2768. Same as ‘%d’ but using the locale’s alternative numeric
  2769. symbols.
  2770. Leading zeroes are permitted but not required.
  2771. ‘%D’
  2772. Equivalent to ‘%m/%d/%y’.
  2773. ‘%F’
  2774. Equivalent to ‘%Y-%m-%d’, which is the ISO 8601 date format.
  2775. This is a GNU extension following an ISO C99 extension to
  2776. ‘strftime’.
  2777. ‘%g’
  2778. The year corresponding to the ISO week number, but without the
  2779. century (range ‘00’ through ‘99’).
  2780. _Note:_ Currently, this is not fully implemented. The format
  2781. is recognized, input is consumed but no field in TM is set.
  2782. This format is a GNU extension following a GNU extension of
  2783. ‘strftime’.
  2784. ‘%G’
  2785. The year corresponding to the ISO week number.
  2786. _Note:_ Currently, this is not fully implemented. The format
  2787. is recognized, input is consumed but no field in TM is set.
  2788. This format is a GNU extension following a GNU extension of
  2789. ‘strftime’.
  2790. ‘%H’
  2791. ‘%k’
  2792. The hour as a decimal number, using a 24-hour clock (range
  2793. ‘00’ through ‘23’).
  2794. ‘%k’ is a GNU extension following a GNU extension of
  2795. ‘strftime’.
  2796. ‘%OH’
  2797. Same as ‘%H’ but using the locale’s alternative numeric
  2798. symbols.
  2799. ‘%I’
  2800. ‘%l’
  2801. The hour as a decimal number, using a 12-hour clock (range
  2802. ‘01’ through ‘12’).
  2803. ‘%l’ is a GNU extension following a GNU extension of
  2804. ‘strftime’.
  2805. ‘%OI’
  2806. Same as ‘%I’ but using the locale’s alternative numeric
  2807. symbols.
  2808. ‘%j’
  2809. The day of the year as a decimal number (range ‘1’ through
  2810. ‘366’).
  2811. Leading zeroes are permitted but not required.
  2812. ‘%m’
  2813. The month as a decimal number (range ‘1’ through ‘12’).
  2814. Leading zeroes are permitted but not required.
  2815. ‘%Om’
  2816. Same as ‘%m’ but using the locale’s alternative numeric
  2817. symbols.
  2818. ‘%M’
  2819. The minute as a decimal number (range ‘0’ through ‘59’).
  2820. Leading zeroes are permitted but not required.
  2821. ‘%OM’
  2822. Same as ‘%M’ but using the locale’s alternative numeric
  2823. symbols.
  2824. ‘%n’
  2825. ‘%t’
  2826. Matches any white space.
  2827. ‘%p’
  2828. ‘%P’
  2829. The locale-dependent equivalent to ‘AM’ or ‘PM’.
  2830. This format is not useful unless ‘%I’ or ‘%l’ is also used.
  2831. Another complication is that the locale might not define these
  2832. values at all and therefore the conversion fails.
  2833. ‘%P’ is a GNU extension following a GNU extension to
  2834. ‘strftime’.
  2835. ‘%r’
  2836. The complete time using the AM/PM format of the current
  2837. locale.
  2838. A complication is that the locale might not define this format
  2839. at all and therefore the conversion fails.
  2840. ‘%R’
  2841. The hour and minute in decimal numbers using the format
  2842. ‘%H:%M’.
  2843. ‘%R’ is a GNU extension following a GNU extension to
  2844. ‘strftime’.
  2845. ‘%s’
  2846. The number of seconds since the epoch, i.e., since 1970-01-01
  2847. 00:00:00 UTC. Leap seconds are not counted unless leap second
  2848. support is available.
  2849. ‘%s’ is a GNU extension following a GNU extension to
  2850. ‘strftime’.
  2851. ‘%S’
  2852. The seconds as a decimal number (range ‘0’ through ‘60’).
  2853. Leading zeroes are permitted but not required.
  2854. *NB:* The Unix specification says the upper bound on this
  2855. value is ‘61’, a result of a decision to allow double leap
  2856. seconds. You will not see the value ‘61’ because no minute
  2857. has more than one leap second, but the myth persists.
  2858. ‘%OS’
  2859. Same as ‘%S’ but using the locale’s alternative numeric
  2860. symbols.
  2861. ‘%T’
  2862. Equivalent to the use of ‘%H:%M:%S’ in this place.
  2863. ‘%u’
  2864. The day of the week as a decimal number (range ‘1’ through
  2865. ‘7’), Monday being ‘1’.
  2866. Leading zeroes are permitted but not required.
  2867. _Note:_ Currently, this is not fully implemented. The format
  2868. is recognized, input is consumed but no field in TM is set.
  2869. ‘%U’
  2870. The week number of the current year as a decimal number (range
  2871. ‘0’ through ‘53’).
  2872. Leading zeroes are permitted but not required.
  2873. ‘%OU’
  2874. Same as ‘%U’ but using the locale’s alternative numeric
  2875. symbols.
  2876. ‘%V’
  2877. The ISO 8601:1988 week number as a decimal number (range ‘1’
  2878. through ‘53’).
  2879. Leading zeroes are permitted but not required.
  2880. _Note:_ Currently, this is not fully implemented. The format
  2881. is recognized, input is consumed but no field in TM is set.
  2882. ‘%w’
  2883. The day of the week as a decimal number (range ‘0’ through
  2884. ‘6’), Sunday being ‘0’.
  2885. Leading zeroes are permitted but not required.
  2886. _Note:_ Currently, this is not fully implemented. The format
  2887. is recognized, input is consumed but no field in TM is set.
  2888. ‘%Ow’
  2889. Same as ‘%w’ but using the locale’s alternative numeric
  2890. symbols.
  2891. ‘%W’
  2892. The week number of the current year as a decimal number (range
  2893. ‘0’ through ‘53’).
  2894. Leading zeroes are permitted but not required.
  2895. _Note:_ Currently, this is not fully implemented. The format
  2896. is recognized, input is consumed but no field in TM is set.
  2897. ‘%OW’
  2898. Same as ‘%W’ but using the locale’s alternative numeric
  2899. symbols.
  2900. ‘%x’
  2901. The date using the locale’s date format.
  2902. ‘%Ex’
  2903. Like ‘%x’ but the locale’s alternative data representation is
  2904. used.
  2905. ‘%X’
  2906. The time using the locale’s time format.
  2907. ‘%EX’
  2908. Like ‘%X’ but the locale’s alternative time representation is
  2909. used.
  2910. ‘%y’
  2911. The year without a century as a decimal number (range ‘0’
  2912. through ‘99’).
  2913. Leading zeroes are permitted but not required.
  2914. Note that it is questionable to use this format without the
  2915. ‘%C’ format. The ‘strptime’ function does regard input values
  2916. in the range 68 to 99 as the years 1969 to 1999 and the values
  2917. 0 to 68 as the years 2000 to 2068. But maybe this heuristic
  2918. fails for some input data.
  2919. Therefore it is best to avoid ‘%y’ completely and use ‘%Y’
  2920. instead.
  2921. ‘%Ey’
  2922. The offset from ‘%EC’ in the locale’s alternative
  2923. representation.
  2924. ‘%Oy’
  2925. The offset of the year (from ‘%C’) using the locale’s
  2926. alternative numeric symbols.
  2927. ‘%Y’
  2928. The year as a decimal number, using the Gregorian calendar.
  2929. ‘%EY’
  2930. The full alternative year representation.
  2931. ‘%z’
  2932. The offset from GMT in ISO 8601/RFC822 format.
  2933. ‘%Z’
  2934. The timezone name.
  2935. _Note:_ Currently, this is not fully implemented. The format
  2936. is recognized, input is consumed but no field in TM is set.
  2937. ‘%%’
  2938. A literal ‘%’ character.
  2939. All other characters in the format string must have a matching
  2940. character in the input string. Exceptions are white spaces in the
  2941. input string which can match zero or more whitespace characters in
  2942. the format string.
  2943. *Portability Note:* The XPG standard advises applications to use at
  2944. least one whitespace character (as specified by ‘isspace’) or other
  2945. non-alphanumeric characters between any two conversion
  2946. specifications. The GNU C Library does not have this limitation
  2947. but other libraries might have trouble parsing formats like
  2948. ‘"%d%m%Y%H%M%S"’.
  2949. The ‘strptime’ function processes the input string from right to
  2950. left. Each of the three possible input elements (white space,
  2951. literal, or format) are handled one after the other. If the input
  2952. cannot be matched to the format string the function stops. The
  2953. remainder of the format and input strings are not processed.
  2954. The function returns a pointer to the first character it was unable
  2955. to process. If the input string contains more characters than
  2956. required by the format string the return value points right after
  2957. the last consumed input character. If the whole input string is
  2958. consumed the return value points to the ‘NULL’ byte at the end of
  2959. the string. If an error occurs, i.e., ‘strptime’ fails to match
  2960. all of the format string, the function returns ‘NULL’.
  2961. The specification of the function in the XPG standard is rather
  2962. vague, leaving out a few important pieces of information. Most
  2963. importantly, it does not specify what happens to those elements of TM
  2964. which are not directly initialized by the different formats. The
  2965. implementations on different Unix systems vary here.
  2966. The GNU C Library implementation does not touch those fields which
  2967. are not directly initialized. Exceptions are the ‘tm_wday’ and
  2968. ‘tm_yday’ elements, which are recomputed if any of the year, month, or
  2969. date elements changed. This has two implications:
  2970. • Before calling the ‘strptime’ function for a new input string, you
  2971. should prepare the TM structure you pass. Normally this will mean
  2972. initializing all values to zero. Alternatively, you can set all
  2973. fields to values like ‘INT_MAX’, allowing you to determine which
  2974. elements were set by the function call. Zero does not work here
  2975. since it is a valid value for many of the fields.
  2976. Careful initialization is necessary if you want to find out whether
  2977. a certain field in TM was initialized by the function call.
  2978. • You can construct a ‘struct tm’ value with several consecutive
  2979. ‘strptime’ calls. A useful application of this is e.g. the
  2980. parsing of two separate strings, one containing date information
  2981. and the other time information. By parsing one after the other
  2982. without clearing the structure in-between, you can construct a
  2983. complete broken-down time.
  2984. The following example shows a function which parses a string which
  2985. contains the date information in either US style or ISO 8601 form:
  2986. const char *
  2987. parse_date (const char *input, struct tm *tm)
  2988. {
  2989. const char *cp;
  2990. /* First clear the result structure. */
  2991. memset (tm, '\0', sizeof (*tm));
  2992. /* Try the ISO format first. */
  2993. cp = strptime (input, "%F", tm);
  2994. if (cp == NULL)
  2995. {
  2996. /* Does not match. Try the US form. */
  2997. cp = strptime (input, "%D", tm);
  2998. }
  2999. return cp;
  3000. }
  3001. 
  3002. File: libc.info, Node: General Time String Parsing, Prev: Low-Level Time String Parsing, Up: Parsing Date and Time
  3003. 21.4.6.2 A More User-friendly Way to Parse Times and Dates
  3004. ..........................................................
  3005. The Unix standard defines another function for parsing date strings.
  3006. The interface is weird, but if the function happens to suit your
  3007. application it is just fine. It is problematic to use this function in
  3008. multi-threaded programs or libraries, since it returns a pointer to a
  3009. static variable, and uses a global variable and global state (an
  3010. environment variable).
  3011. -- Variable: getdate_err
  3012. This variable of type ‘int’ contains the error code of the last
  3013. unsuccessful call to ‘getdate’. Defined values are:
  3014. 1
  3015. The environment variable ‘DATEMSK’ is not defined or null.
  3016. 2
  3017. The template file denoted by the ‘DATEMSK’ environment
  3018. variable cannot be opened.
  3019. 3
  3020. Information about the template file cannot retrieved.
  3021. 4
  3022. The template file is not a regular file.
  3023. 5
  3024. An I/O error occurred while reading the template file.
  3025. 6
  3026. Not enough memory available to execute the function.
  3027. 7
  3028. The template file contains no matching template.
  3029. 8
  3030. The input date is invalid, but would match a template
  3031. otherwise. This includes dates like February 31st, and dates
  3032. which cannot be represented in a ‘time_t’ variable.
  3033. -- Function: struct tm * getdate (const char *STRING)
  3034. Preliminary: | MT-Unsafe race:getdate env locale | AS-Unsafe heap
  3035. lock | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  3036. The interface to ‘getdate’ is the simplest possible for a function
  3037. to parse a string and return the value. STRING is the input string
  3038. and the result is returned in a statically-allocated variable.
  3039. The details about how the string is processed are hidden from the
  3040. user. In fact, they can be outside the control of the program.
  3041. Which formats are recognized is controlled by the file named by the
  3042. environment variable ‘DATEMSK’. This file should contain lines of
  3043. valid format strings which could be passed to ‘strptime’.
  3044. The ‘getdate’ function reads these format strings one after the
  3045. other and tries to match the input string. The first line which
  3046. completely matches the input string is used.
  3047. Elements not initialized through the format string retain the
  3048. values present at the time of the ‘getdate’ function call.
  3049. The formats recognized by ‘getdate’ are the same as for ‘strptime’.
  3050. See above for an explanation. There are only a few extensions to
  3051. the ‘strptime’ behavior:
  3052. • If the ‘%Z’ format is given the broken-down time is based on
  3053. the current time of the timezone matched, not of the current
  3054. timezone of the runtime environment.
  3055. _Note_: This is not implemented (currently). The problem is
  3056. that timezone names are not unique. If a fixed timezone is
  3057. assumed for a given string (say ‘EST’ meaning US East Coast
  3058. time), then uses for countries other than the USA will fail.
  3059. So far we have found no good solution to this.
  3060. • If only the weekday is specified the selected day depends on
  3061. the current date. If the current weekday is greater than or
  3062. equal to the ‘tm_wday’ value the current week’s day is chosen,
  3063. otherwise the day next week is chosen.
  3064. • A similar heuristic is used when only the month is given and
  3065. not the year. If the month is greater than or equal to the
  3066. current month, then the current year is used. Otherwise it
  3067. wraps to next year. The first day of the month is assumed if
  3068. one is not explicitly specified.
  3069. • The current hour, minute, and second are used if the
  3070. appropriate value is not set through the format.
  3071. • If no date is given tomorrow’s date is used if the time is
  3072. smaller than the current time. Otherwise today’s date is
  3073. taken.
  3074. It should be noted that the format in the template file need not
  3075. only contain format elements. The following is a list of possible
  3076. format strings (taken from the Unix standard):
  3077. %m
  3078. %A %B %d, %Y %H:%M:%S
  3079. %A
  3080. %B
  3081. %m/%d/%y %I %p
  3082. %d,%m,%Y %H:%M
  3083. at %A the %dst of %B in %Y
  3084. run job at %I %p,%B %dnd
  3085. %A den %d. %B %Y %H.%M Uhr
  3086. As you can see, the template list can contain very specific strings
  3087. like ‘run job at %I %p,%B %dnd’. Using the above list of templates
  3088. and assuming the current time is Mon Sep 22 12:19:47 EDT 1986, we
  3089. can obtain the following results for the given input.
  3090. Input Match Result
  3091. Mon %a Mon Sep 22 12:19:47 EDT 1986
  3092. Sun %a Sun Sep 28 12:19:47 EDT 1986
  3093. Fri %a Fri Sep 26 12:19:47 EDT 1986
  3094. September %B Mon Sep 1 12:19:47 EDT 1986
  3095. January %B Thu Jan 1 12:19:47 EST 1987
  3096. December %B Mon Dec 1 12:19:47 EST 1986
  3097. Sep Mon %b %a Mon Sep 1 12:19:47 EDT 1986
  3098. Jan Fri %b %a Fri Jan 2 12:19:47 EST 1987
  3099. Dec Mon %b %a Mon Dec 1 12:19:47 EST 1986
  3100. Jan Wed 1989 %b %a %Y Wed Jan 4 12:19:47 EST 1989
  3101. Fri 9 %a %H Fri Sep 26 09:00:00 EDT 1986
  3102. Feb 10:30 %b %H:%S Sun Feb 1 10:00:30 EST 1987
  3103. 10:30 %H:%M Tue Sep 23 10:30:00 EDT 1986
  3104. 13:30 %H:%M Mon Sep 22 13:30:00 EDT 1986
  3105. The return value of the function is a pointer to a static variable
  3106. of type ‘struct tm’, or a null pointer if an error occurred. The
  3107. result is only valid until the next ‘getdate’ call, making this
  3108. function unusable in multi-threaded applications.
  3109. The ‘errno’ variable is _not_ changed. Error conditions are stored
  3110. in the global variable ‘getdate_err’. See the description above
  3111. for a list of the possible error values.
  3112. _Warning:_ The ‘getdate’ function should _never_ be used in
  3113. SUID-programs. The reason is obvious: using the ‘DATEMSK’
  3114. environment variable you can get the function to open any arbitrary
  3115. file and chances are high that with some bogus input (such as a
  3116. binary file) the program will crash.
  3117. -- Function: int getdate_r (const char *STRING, struct tm *TP)
  3118. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  3119. lock mem fd | *Note POSIX Safety Concepts::.
  3120. The ‘getdate_r’ function is the reentrant counterpart of ‘getdate’.
  3121. It does not use the global variable ‘getdate_err’ to signal an
  3122. error, but instead returns an error code. The same error codes as
  3123. described in the ‘getdate_err’ documentation above are used, with 0
  3124. meaning success.
  3125. Moreover, ‘getdate_r’ stores the broken-down time in the variable
  3126. of type ‘struct tm’ pointed to by the second argument, rather than
  3127. in a static variable.
  3128. This function is not defined in the Unix standard. Nevertheless it
  3129. is available on some other Unix systems as well.
  3130. The warning against using ‘getdate’ in SUID-programs applies to
  3131. ‘getdate_r’ as well.
  3132. 
  3133. File: libc.info, Node: TZ Variable, Next: Time Zone Functions, Prev: Parsing Date and Time, Up: Calendar Time
  3134. 21.4.7 Specifying the Time Zone with ‘TZ’
  3135. -----------------------------------------
  3136. In POSIX systems, a user can specify the time zone by means of the ‘TZ’
  3137. environment variable. For information about how to set environment
  3138. variables, see *note Environment Variables::. The functions for
  3139. accessing the time zone are declared in ‘time.h’.
  3140. You should not normally need to set ‘TZ’. If the system is
  3141. configured properly, the default time zone will be correct. You might
  3142. set ‘TZ’ if you are using a computer over a network from a different
  3143. time zone, and would like times reported to you in the time zone local
  3144. to you, rather than what is local to the computer.
  3145. In POSIX.1 systems the value of the ‘TZ’ variable can be in one of
  3146. three formats. With the GNU C Library, the most common format is the
  3147. last one, which can specify a selection from a large database of time
  3148. zone information for many regions of the world. The first two formats
  3149. are used to describe the time zone information directly, which is both
  3150. more cumbersome and less precise. But the POSIX.1 standard only
  3151. specifies the details of the first two formats, so it is good to be
  3152. familiar with them in case you come across a POSIX.1 system that doesn’t
  3153. support a time zone information database.
  3154. The first format is used when there is no Daylight Saving Time (or
  3155. summer time) in the local time zone:
  3156. STD OFFSET
  3157. The STD string specifies the name of the time zone. It must be three
  3158. or more characters long and must not contain a leading colon, embedded
  3159. digits, commas, nor plus and minus signs. There is no space character
  3160. separating the time zone name from the OFFSET, so these restrictions are
  3161. necessary to parse the specification correctly.
  3162. The OFFSET specifies the time value you must add to the local time to
  3163. get a Coordinated Universal Time value. It has syntax like
  3164. [‘+’|‘-’]HH[‘:’MM[‘:’SS]]. This is positive if the local time zone is
  3165. west of the Prime Meridian and negative if it is east. The hour must be
  3166. between ‘0’ and ‘24’, and the minute and seconds between ‘0’ and ‘59’.
  3167. For example, here is how we would specify Eastern Standard Time, but
  3168. without any Daylight Saving Time alternative:
  3169. EST+5
  3170. The second format is used when there is Daylight Saving Time:
  3171. STD OFFSET DST [OFFSET]‘,’START[‘/’TIME]‘,’END[‘/’TIME]
  3172. The initial STD and OFFSET specify the standard time zone, as
  3173. described above. The DST string and OFFSET specify the name and offset
  3174. for the corresponding Daylight Saving Time zone; if the OFFSET is
  3175. omitted, it defaults to one hour ahead of standard time.
  3176. The remainder of the specification describes when Daylight Saving
  3177. Time is in effect. The START field is when Daylight Saving Time goes
  3178. into effect and the END field is when the change is made back to
  3179. standard time. The following formats are recognized for these fields:
  3180. ‘JN’
  3181. This specifies the Julian day, with N between ‘1’ and ‘365’.
  3182. February 29 is never counted, even in leap years.
  3183. ‘N’
  3184. This specifies the Julian day, with N between ‘0’ and ‘365’.
  3185. February 29 is counted in leap years.
  3186. ‘MM.W.D’
  3187. This specifies day D of week W of month M. The day D must be
  3188. between ‘0’ (Sunday) and ‘6’. The week W must be between ‘1’ and
  3189. ‘5’; week ‘1’ is the first week in which day D occurs, and week ‘5’
  3190. specifies the _last_ D day in the month. The month M should be
  3191. between ‘1’ and ‘12’.
  3192. The TIME fields specify when, in the local time currently in effect,
  3193. the change to the other time occurs. If omitted, the default is
  3194. ‘02:00:00’. The hours part of the time fields can range from −167
  3195. through 167; this is an extension to POSIX.1, which allows only the
  3196. range 0 through 24.
  3197. Here are some example ‘TZ’ values, including the appropriate Daylight
  3198. Saving Time and its dates of applicability. In North American Eastern
  3199. Standard Time (EST) and Eastern Daylight Time (EDT), the normal offset
  3200. from UTC is 5 hours; since this is west of the prime meridian, the sign
  3201. is positive. Summer time begins on March’s second Sunday at 2:00am, and
  3202. ends on November’s first Sunday at 2:00am.
  3203. EST+5EDT,M3.2.0/2,M11.1.0/2
  3204. Israel Standard Time (IST) and Israel Daylight Time (IDT) are 2 hours
  3205. ahead of the prime meridian in winter, springing forward an hour on
  3206. March’s fourth Thursday at 26:00 (i.e., 02:00 on the first Friday on or
  3207. after March 23), and falling back on October’s last Sunday at 02:00.
  3208. IST-2IDT,M3.4.4/26,M10.5.0
  3209. Western Argentina Summer Time (WARST) is 3 hours behind the prime
  3210. meridian all year. There is a dummy fall-back transition on December 31
  3211. at 25:00 daylight saving time (i.e., 24:00 standard time, equivalent to
  3212. January 1 at 00:00 standard time), and a simultaneous spring-forward
  3213. transition on January 1 at 00:00 standard time, so daylight saving time
  3214. is in effect all year and the initial ‘WART’ is a placeholder.
  3215. WART4WARST,J1/0,J365/25
  3216. Western Greenland Time (WGT) and Western Greenland Summer Time (WGST)
  3217. are 3 hours behind UTC in the winter. Its clocks follow the European
  3218. Union rules of springing forward by one hour on March’s last Sunday at
  3219. 01:00 UTC (−02:00 local time) and falling back on October’s last Sunday
  3220. at 01:00 UTC (−01:00 local time).
  3221. WGT3WGST,M3.5.0/-2,M10.5.0/-1
  3222. The schedule of Daylight Saving Time in any particular jurisdiction
  3223. has changed over the years. To be strictly correct, the conversion of
  3224. dates and times in the past should be based on the schedule that was in
  3225. effect then. However, this format has no facilities to let you specify
  3226. how the schedule has changed from year to year. The most you can do is
  3227. specify one particular schedule—usually the present day schedule—and
  3228. this is used to convert any date, no matter when. For precise time zone
  3229. specifications, it is best to use the time zone information database
  3230. (see below).
  3231. The third format looks like this:
  3232. :CHARACTERS
  3233. Each operating system interprets this format differently; in the GNU
  3234. C Library, CHARACTERS is the name of a file which describes the time
  3235. zone.
  3236. If the ‘TZ’ environment variable does not have a value, the operation
  3237. chooses a time zone by default. In the GNU C Library, the default time
  3238. zone is like the specification ‘TZ=:/etc/localtime’ (or
  3239. ‘TZ=:/usr/local/etc/localtime’, depending on how the GNU C Library was
  3240. configured; *note Installation::). Other C libraries use their own rule
  3241. for choosing the default time zone, so there is little we can say about
  3242. them.
  3243. If CHARACTERS begins with a slash, it is an absolute file name;
  3244. otherwise the library looks for the file
  3245. ‘/usr/share/zoneinfo/CHARACTERS’. The ‘zoneinfo’ directory contains
  3246. data files describing local time zones in many different parts of the
  3247. world. The names represent major cities, with subdirectories for
  3248. geographical areas; for example, ‘America/New_York’, ‘Europe/London’,
  3249. ‘Asia/Hong_Kong’. These data files are installed by the system
  3250. administrator, who also sets ‘/etc/localtime’ to point to the data file
  3251. for the local time zone. The files typically come from the Time Zone
  3252. Database (http://www.iana.org/time-zones) of time zone and daylight
  3253. saving time information for most regions of the world, which is
  3254. maintained by a community of volunteers and put in the public domain.
  3255. 
  3256. File: libc.info, Node: Time Zone Functions, Next: Time Functions Example, Prev: TZ Variable, Up: Calendar Time
  3257. 21.4.8 Functions and Variables for Time Zones
  3258. ---------------------------------------------
  3259. -- Variable: char * tzname [2]
  3260. The array ‘tzname’ contains two strings, which are the standard
  3261. names of the pair of time zones (standard and Daylight Saving) that
  3262. the user has selected. ‘tzname[0]’ is the name of the standard
  3263. time zone (for example, ‘"EST"’), and ‘tzname[1]’ is the name for
  3264. the time zone when Daylight Saving Time is in use (for example,
  3265. ‘"EDT"’). These correspond to the STD and DST strings
  3266. (respectively) from the ‘TZ’ environment variable. If Daylight
  3267. Saving Time is never used, ‘tzname[1]’ is the empty string.
  3268. The ‘tzname’ array is initialized from the ‘TZ’ environment
  3269. variable whenever ‘tzset’, ‘ctime’, ‘strftime’, ‘mktime’, or
  3270. ‘localtime’ is called. If multiple abbreviations have been used
  3271. (e.g. ‘"EWT"’ and ‘"EDT"’ for U.S. Eastern War Time and Eastern
  3272. Daylight Time), the array contains the most recent abbreviation.
  3273. The ‘tzname’ array is required for POSIX.1 compatibility, but in
  3274. GNU programs it is better to use the ‘tm_zone’ member of the
  3275. broken-down time structure, since ‘tm_zone’ reports the correct
  3276. abbreviation even when it is not the latest one.
  3277. Though the strings are declared as ‘char *’ the user must refrain
  3278. from modifying these strings. Modifying the strings will almost
  3279. certainly lead to trouble.
  3280. -- Function: void tzset (void)
  3281. Preliminary: | MT-Safe env locale | AS-Unsafe heap lock | AC-Unsafe
  3282. lock mem fd | *Note POSIX Safety Concepts::.
  3283. The ‘tzset’ function initializes the ‘tzname’ variable from the
  3284. value of the ‘TZ’ environment variable. It is not usually
  3285. necessary for your program to call this function, because it is
  3286. called automatically when you use the other time conversion
  3287. functions that depend on the time zone.
  3288. The following variables are defined for compatibility with System V
  3289. Unix. Like ‘tzname’, these variables are set by calling ‘tzset’ or the
  3290. other time conversion functions.
  3291. -- Variable: long int timezone
  3292. This contains the difference between UTC and the latest local
  3293. standard time, in seconds west of UTC. For example, in the U.S.
  3294. Eastern time zone, the value is ‘5*60*60’. Unlike the ‘tm_gmtoff’
  3295. member of the broken-down time structure, this value is not
  3296. adjusted for daylight saving, and its sign is reversed. In GNU
  3297. programs it is better to use ‘tm_gmtoff’, since it contains the
  3298. correct offset even when it is not the latest one.
  3299. -- Variable: int daylight
  3300. This variable has a nonzero value if Daylight Saving Time rules
  3301. apply. A nonzero value does not necessarily mean that Daylight
  3302. Saving Time is now in effect; it means only that Daylight Saving
  3303. Time is sometimes in effect.
  3304. 
  3305. File: libc.info, Node: Time Functions Example, Prev: Time Zone Functions, Up: Calendar Time
  3306. 21.4.9 Time Functions Example
  3307. -----------------------------
  3308. Here is an example program showing the use of some of the calendar time
  3309. functions.
  3310. #include <time.h>
  3311. #include <stdio.h>
  3312. #define SIZE 256
  3313. int
  3314. main (void)
  3315. {
  3316. char buffer[SIZE];
  3317. time_t curtime;
  3318. struct tm *loctime;
  3319. /* Get the current time. */
  3320. curtime = time (NULL);
  3321. /* Convert it to local time representation. */
  3322. loctime = localtime (&curtime);
  3323. /* Print out the date and time in the standard format. */
  3324. fputs (asctime (loctime), stdout);
  3325. /* Print it out in a nice format. */
  3326. strftime (buffer, SIZE, "Today is %A, %B %d.\n", loctime);
  3327. fputs (buffer, stdout);
  3328. strftime (buffer, SIZE, "The time is %I:%M %p.\n", loctime);
  3329. fputs (buffer, stdout);
  3330. return 0;
  3331. }
  3332. It produces output like this:
  3333. Wed Jul 31 13:02:36 1991
  3334. Today is Wednesday, July 31.
  3335. The time is 01:02 PM.
  3336. 
  3337. File: libc.info, Node: Setting an Alarm, Next: Sleeping, Prev: Calendar Time, Up: Date and Time
  3338. 21.5 Setting an Alarm
  3339. =====================
  3340. The ‘alarm’ and ‘setitimer’ functions provide a mechanism for a process
  3341. to interrupt itself in the future. They do this by setting a timer;
  3342. when the timer expires, the process receives a signal.
  3343. Each process has three independent interval timers available:
  3344. • A real-time timer that counts elapsed time. This timer sends a
  3345. ‘SIGALRM’ signal to the process when it expires.
  3346. • A virtual timer that counts processor time used by the process.
  3347. This timer sends a ‘SIGVTALRM’ signal to the process when it
  3348. expires.
  3349. • A profiling timer that counts both processor time used by the
  3350. process, and processor time spent in system calls on behalf of the
  3351. process. This timer sends a ‘SIGPROF’ signal to the process when
  3352. it expires.
  3353. This timer is useful for profiling in interpreters. The interval
  3354. timer mechanism does not have the fine granularity necessary for
  3355. profiling native code.
  3356. You can only have one timer of each kind set at any given time. If
  3357. you set a timer that has not yet expired, that timer is simply reset to
  3358. the new value.
  3359. You should establish a handler for the appropriate alarm signal using
  3360. ‘signal’ or ‘sigaction’ before issuing a call to ‘setitimer’ or ‘alarm’.
  3361. Otherwise, an unusual chain of events could cause the timer to expire
  3362. before your program establishes the handler. In this case it would be
  3363. terminated, since termination is the default action for the alarm
  3364. signals. *Note Signal Handling::.
  3365. To be able to use the alarm function to interrupt a system call which
  3366. might block otherwise indefinitely it is important to _not_ set the
  3367. ‘SA_RESTART’ flag when registering the signal handler using ‘sigaction’.
  3368. When not using ‘sigaction’ things get even uglier: the ‘signal’ function
  3369. has fixed semantics with respect to restarts. The BSD semantics for
  3370. this function is to set the flag. Therefore, if ‘sigaction’ for
  3371. whatever reason cannot be used, it is necessary to use ‘sysv_signal’ and
  3372. not ‘signal’.
  3373. The ‘setitimer’ function is the primary means for setting an alarm.
  3374. This facility is declared in the header file ‘sys/time.h’. The ‘alarm’
  3375. function, declared in ‘unistd.h’, provides a somewhat simpler interface
  3376. for setting the real-time timer.
  3377. -- Data Type: struct itimerval
  3378. This structure is used to specify when a timer should expire. It
  3379. contains the following members:
  3380. ‘struct timeval it_interval’
  3381. This is the period between successive timer interrupts. If
  3382. zero, the alarm will only be sent once.
  3383. ‘struct timeval it_value’
  3384. This is the period between now and the first timer interrupt.
  3385. If zero, the alarm is disabled.
  3386. The ‘struct timeval’ data type is described in *note Elapsed
  3387. Time::.
  3388. -- Function: int setitimer (int WHICH, const struct itimerval *NEW,
  3389. struct itimerval *OLD)
  3390. Preliminary: | MT-Safe timer | AS-Safe | AC-Safe | *Note POSIX
  3391. Safety Concepts::.
  3392. The ‘setitimer’ function sets the timer specified by WHICH
  3393. according to NEW. The WHICH argument can have a value of
  3394. ‘ITIMER_REAL’, ‘ITIMER_VIRTUAL’, or ‘ITIMER_PROF’.
  3395. If OLD is not a null pointer, ‘setitimer’ returns information about
  3396. any previous unexpired timer of the same kind in the structure it
  3397. points to.
  3398. The return value is ‘0’ on success and ‘-1’ on failure. The
  3399. following ‘errno’ error conditions are defined for this function:
  3400. ‘EINVAL’
  3401. The timer period is too large.
  3402. -- Function: int getitimer (int WHICH, struct itimerval *OLD)
  3403. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3404. Concepts::.
  3405. The ‘getitimer’ function stores information about the timer
  3406. specified by WHICH in the structure pointed at by OLD.
  3407. The return value and error conditions are the same as for
  3408. ‘setitimer’.
  3409. ‘ITIMER_REAL’
  3410. This constant can be used as the WHICH argument to the ‘setitimer’
  3411. and ‘getitimer’ functions to specify the real-time timer.
  3412. ‘ITIMER_VIRTUAL’
  3413. This constant can be used as the WHICH argument to the ‘setitimer’
  3414. and ‘getitimer’ functions to specify the virtual timer.
  3415. ‘ITIMER_PROF’
  3416. This constant can be used as the WHICH argument to the ‘setitimer’
  3417. and ‘getitimer’ functions to specify the profiling timer.
  3418. -- Function: unsigned int alarm (unsigned int SECONDS)
  3419. Preliminary: | MT-Safe timer | AS-Safe | AC-Safe | *Note POSIX
  3420. Safety Concepts::.
  3421. The ‘alarm’ function sets the real-time timer to expire in SECONDS
  3422. seconds. If you want to cancel any existing alarm, you can do this
  3423. by calling ‘alarm’ with a SECONDS argument of zero.
  3424. The return value indicates how many seconds remain before the
  3425. previous alarm would have been sent. If there was no previous
  3426. alarm, ‘alarm’ returns zero.
  3427. The ‘alarm’ function could be defined in terms of ‘setitimer’ like
  3428. this:
  3429. unsigned int
  3430. alarm (unsigned int seconds)
  3431. {
  3432. struct itimerval old, new;
  3433. new.it_interval.tv_usec = 0;
  3434. new.it_interval.tv_sec = 0;
  3435. new.it_value.tv_usec = 0;
  3436. new.it_value.tv_sec = (long int) seconds;
  3437. if (setitimer (ITIMER_REAL, &new, &old) < 0)
  3438. return 0;
  3439. else
  3440. return old.it_value.tv_sec;
  3441. }
  3442. There is an example showing the use of the ‘alarm’ function in *note
  3443. Handler Returns::.
  3444. If you simply want your process to wait for a given number of
  3445. seconds, you should use the ‘sleep’ function. *Note Sleeping::.
  3446. You shouldn’t count on the signal arriving precisely when the timer
  3447. expires. In a multiprocessing environment there is typically some
  3448. amount of delay involved.
  3449. *Portability Note:* The ‘setitimer’ and ‘getitimer’ functions are
  3450. derived from BSD Unix, while the ‘alarm’ function is specified by the
  3451. POSIX.1 standard. ‘setitimer’ is more powerful than ‘alarm’, but
  3452. ‘alarm’ is more widely used.
  3453. 
  3454. File: libc.info, Node: Sleeping, Prev: Setting an Alarm, Up: Date and Time
  3455. 21.6 Sleeping
  3456. =============
  3457. The function ‘sleep’ gives a simple way to make the program wait for a
  3458. short interval. If your program doesn’t use signals (except to
  3459. terminate), then you can expect ‘sleep’ to wait reliably throughout the
  3460. specified interval. Otherwise, ‘sleep’ can return sooner if a signal
  3461. arrives; if you want to wait for a given interval regardless of signals,
  3462. use ‘select’ (*note Waiting for I/O::) and don’t specify any descriptors
  3463. to wait for.
  3464. -- Function: unsigned int sleep (unsigned int SECONDS)
  3465. Preliminary: | MT-Unsafe sig:SIGCHLD/linux | AS-Unsafe | AC-Unsafe
  3466. | *Note POSIX Safety Concepts::.
  3467. The ‘sleep’ function waits for SECONDS seconds or until a signal is
  3468. delivered, whichever happens first.
  3469. If ‘sleep’ returns because the requested interval is over, it
  3470. returns a value of zero. If it returns because of delivery of a
  3471. signal, its return value is the remaining time in the sleep
  3472. interval.
  3473. The ‘sleep’ function is declared in ‘unistd.h’.
  3474. Resist the temptation to implement a sleep for a fixed amount of time
  3475. by using the return value of ‘sleep’, when nonzero, to call ‘sleep’
  3476. again. This will work with a certain amount of accuracy as long as
  3477. signals arrive infrequently. But each signal can cause the eventual
  3478. wakeup time to be off by an additional second or so. Suppose a few
  3479. signals happen to arrive in rapid succession by bad luck—there is no
  3480. limit on how much this could shorten or lengthen the wait.
  3481. Instead, compute the calendar time at which the program should stop
  3482. waiting, and keep trying to wait until that calendar time. This won’t
  3483. be off by more than a second. With just a little more work, you can use
  3484. ‘select’ and make the waiting period quite accurate. (Of course, heavy
  3485. system load can cause additional unavoidable delays—unless the machine
  3486. is dedicated to one application, there is no way you can avoid this.)
  3487. On some systems, ‘sleep’ can do strange things if your program uses
  3488. ‘SIGALRM’ explicitly. Even if ‘SIGALRM’ signals are being ignored or
  3489. blocked when ‘sleep’ is called, ‘sleep’ might return prematurely on
  3490. delivery of a ‘SIGALRM’ signal. If you have established a handler for
  3491. ‘SIGALRM’ signals and a ‘SIGALRM’ signal is delivered while the process
  3492. is sleeping, the action taken might be just to cause ‘sleep’ to return
  3493. instead of invoking your handler. And, if ‘sleep’ is interrupted by
  3494. delivery of a signal whose handler requests an alarm or alters the
  3495. handling of ‘SIGALRM’, this handler and ‘sleep’ will interfere.
  3496. On GNU systems, it is safe to use ‘sleep’ and ‘SIGALRM’ in the same
  3497. program, because ‘sleep’ does not work by means of ‘SIGALRM’.
  3498. -- Function: int nanosleep (const struct timespec *REQUESTED_TIME,
  3499. struct timespec *REMAINING)
  3500. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3501. Concepts::.
  3502. If resolution to seconds is not enough the ‘nanosleep’ function can
  3503. be used. As the name suggests the sleep interval can be specified
  3504. in nanoseconds. The actual elapsed time of the sleep interval
  3505. might be longer since the system rounds the elapsed time you
  3506. request up to the next integer multiple of the actual resolution
  3507. the system can deliver.
  3508. *‘requested_time’ is the elapsed time of the interval you want to
  3509. sleep.
  3510. The function returns as *‘remaining’ the elapsed time left in the
  3511. interval for which you requested to sleep. If the interval
  3512. completed without getting interrupted by a signal, this is zero.
  3513. ‘struct timespec’ is described in *Note Elapsed Time::.
  3514. If the function returns because the interval is over the return
  3515. value is zero. If the function returns -1 the global variable
  3516. ERRNO is set to the following values:
  3517. ‘EINTR’
  3518. The call was interrupted because a signal was delivered to the
  3519. thread. If the REMAINING parameter is not the null pointer
  3520. the structure pointed to by REMAINING is updated to contain
  3521. the remaining elapsed time.
  3522. ‘EINVAL’
  3523. The nanosecond value in the REQUESTED_TIME parameter contains
  3524. an illegal value. Either the value is negative or greater
  3525. than or equal to 1000 million.
  3526. This function is a cancellation point in multi-threaded programs.
  3527. This is a problem if the thread allocates some resources (like
  3528. memory, file descriptors, semaphores or whatever) at the time
  3529. ‘nanosleep’ is called. If the thread gets canceled these resources
  3530. stay allocated until the program ends. To avoid this calls to
  3531. ‘nanosleep’ should be protected using cancellation handlers.
  3532. The ‘nanosleep’ function is declared in ‘time.h’.
  3533. 
  3534. File: libc.info, Node: Resource Usage And Limitation, Next: Non-Local Exits, Prev: Date and Time, Up: Top
  3535. 22 Resource Usage And Limitation
  3536. ********************************
  3537. This chapter describes functions for examining how much of various kinds
  3538. of resources (CPU time, memory, etc.) a process has used and getting
  3539. and setting limits on future usage.
  3540. * Menu:
  3541. * Resource Usage:: Measuring various resources used.
  3542. * Limits on Resources:: Specifying limits on resource usage.
  3543. * Priority:: Reading or setting process run priority.
  3544. * Memory Resources:: Querying memory available resources.
  3545. * Processor Resources:: Learn about the processors available.
  3546. 
  3547. File: libc.info, Node: Resource Usage, Next: Limits on Resources, Up: Resource Usage And Limitation
  3548. 22.1 Resource Usage
  3549. ===================
  3550. The function ‘getrusage’ and the data type ‘struct rusage’ are used to
  3551. examine the resource usage of a process. They are declared in
  3552. ‘sys/resource.h’.
  3553. -- Function: int getrusage (int PROCESSES, struct rusage *RUSAGE)
  3554. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3555. Concepts::.
  3556. This function reports resource usage totals for processes specified
  3557. by PROCESSES, storing the information in ‘*RUSAGE’.
  3558. In most systems, PROCESSES has only two valid values:
  3559. ‘RUSAGE_SELF’
  3560. Just the current process.
  3561. ‘RUSAGE_CHILDREN’
  3562. All child processes (direct and indirect) that have already
  3563. terminated.
  3564. The return value of ‘getrusage’ is zero for success, and ‘-1’ for
  3565. failure.
  3566. ‘EINVAL’
  3567. The argument PROCESSES is not valid.
  3568. One way of getting resource usage for a particular child process is
  3569. with the function ‘wait4’, which returns totals for a child when it
  3570. terminates. *Note BSD Wait Functions::.
  3571. -- Data Type: struct rusage
  3572. This data type stores various resource usage statistics. It has
  3573. the following members, and possibly others:
  3574. ‘struct timeval ru_utime’
  3575. Time spent executing user instructions.
  3576. ‘struct timeval ru_stime’
  3577. Time spent in operating system code on behalf of PROCESSES.
  3578. ‘long int ru_maxrss’
  3579. The maximum resident set size used, in kilobytes. That is,
  3580. the maximum number of kilobytes of physical memory that
  3581. PROCESSES used simultaneously.
  3582. ‘long int ru_ixrss’
  3583. An integral value expressed in kilobytes times ticks of
  3584. execution, which indicates the amount of memory used by text
  3585. that was shared with other processes.
  3586. ‘long int ru_idrss’
  3587. An integral value expressed the same way, which is the amount
  3588. of unshared memory used for data.
  3589. ‘long int ru_isrss’
  3590. An integral value expressed the same way, which is the amount
  3591. of unshared memory used for stack space.
  3592. ‘long int ru_minflt’
  3593. The number of page faults which were serviced without
  3594. requiring any I/O.
  3595. ‘long int ru_majflt’
  3596. The number of page faults which were serviced by doing I/O.
  3597. ‘long int ru_nswap’
  3598. The number of times PROCESSES was swapped entirely out of main
  3599. memory.
  3600. ‘long int ru_inblock’
  3601. The number of times the file system had to read from the disk
  3602. on behalf of PROCESSES.
  3603. ‘long int ru_oublock’
  3604. The number of times the file system had to write to the disk
  3605. on behalf of PROCESSES.
  3606. ‘long int ru_msgsnd’
  3607. Number of IPC messages sent.
  3608. ‘long int ru_msgrcv’
  3609. Number of IPC messages received.
  3610. ‘long int ru_nsignals’
  3611. Number of signals received.
  3612. ‘long int ru_nvcsw’
  3613. The number of times PROCESSES voluntarily invoked a context
  3614. switch (usually to wait for some service).
  3615. ‘long int ru_nivcsw’
  3616. The number of times an involuntary context switch took place
  3617. (because a time slice expired, or another process of higher
  3618. priority was scheduled).
  3619. ‘vtimes’ is a historical function that does some of what ‘getrusage’
  3620. does. ‘getrusage’ is a better choice.
  3621. ‘vtimes’ and its ‘vtimes’ data structure are declared in
  3622. ‘sys/vtimes.h’.
  3623. -- Function: int vtimes (struct vtimes *CURRENT, struct vtimes *CHILD)
  3624. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3625. Concepts::.
  3626. ‘vtimes’ reports resource usage totals for a process.
  3627. If CURRENT is non-null, ‘vtimes’ stores resource usage totals for
  3628. the invoking process alone in the structure to which it points. If
  3629. CHILD is non-null, ‘vtimes’ stores resource usage totals for all
  3630. past children (which have terminated) of the invoking process in
  3631. the structure to which it points.
  3632. -- Data Type: struct vtimes
  3633. This data type contains information about the resource usage
  3634. of a process. Each member corresponds to a member of the
  3635. ‘struct rusage’ data type described above.
  3636. ‘vm_utime’
  3637. User CPU time. Analogous to ‘ru_utime’ in ‘struct
  3638. rusage’
  3639. ‘vm_stime’
  3640. System CPU time. Analogous to ‘ru_stime’ in ‘struct
  3641. rusage’
  3642. ‘vm_idsrss’
  3643. Data and stack memory. The sum of the values that would
  3644. be reported as ‘ru_idrss’ and ‘ru_isrss’ in ‘struct
  3645. rusage’
  3646. ‘vm_ixrss’
  3647. Shared memory. Analogous to ‘ru_ixrss’ in ‘struct
  3648. rusage’
  3649. ‘vm_maxrss’
  3650. Maximent resident set size. Analogous to ‘ru_maxrss’ in
  3651. ‘struct rusage’
  3652. ‘vm_majflt’
  3653. Major page faults. Analogous to ‘ru_majflt’ in ‘struct
  3654. rusage’
  3655. ‘vm_minflt’
  3656. Minor page faults. Analogous to ‘ru_minflt’ in ‘struct
  3657. rusage’
  3658. ‘vm_nswap’
  3659. Swap count. Analogous to ‘ru_nswap’ in ‘struct rusage’
  3660. ‘vm_inblk’
  3661. Disk reads. Analogous to ‘ru_inblk’ in ‘struct rusage’
  3662. ‘vm_oublk’
  3663. Disk writes. Analogous to ‘ru_oublk’ in ‘struct rusage’
  3664. The return value is zero if the function succeeds; ‘-1’ otherwise.
  3665. An additional historical function for examining resource usage,
  3666. ‘vtimes’, is supported but not documented here. It is declared in
  3667. ‘sys/vtimes.h’.
  3668. 
  3669. File: libc.info, Node: Limits on Resources, Next: Priority, Prev: Resource Usage, Up: Resource Usage And Limitation
  3670. 22.2 Limiting Resource Usage
  3671. ============================
  3672. You can specify limits for the resource usage of a process. When the
  3673. process tries to exceed a limit, it may get a signal, or the system call
  3674. by which it tried to do so may fail, depending on the resource. Each
  3675. process initially inherits its limit values from its parent, but it can
  3676. subsequently change them.
  3677. There are two per-process limits associated with a resource:
  3678. "current limit"
  3679. The current limit is the value the system will not allow usage to
  3680. exceed. It is also called the “soft limit” because the process
  3681. being limited can generally raise the current limit at will.
  3682. "maximum limit"
  3683. The maximum limit is the maximum value to which a process is
  3684. allowed to set its current limit. It is also called the “hard
  3685. limit” because there is no way for a process to get around it. A
  3686. process may lower its own maximum limit, but only the superuser may
  3687. increase a maximum limit.
  3688. The symbols for use with ‘getrlimit’, ‘setrlimit’, ‘getrlimit64’, and
  3689. ‘setrlimit64’ are defined in ‘sys/resource.h’.
  3690. -- Function: int getrlimit (int RESOURCE, struct rlimit *RLP)
  3691. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3692. Concepts::.
  3693. Read the current and maximum limits for the resource RESOURCE and
  3694. store them in ‘*RLP’.
  3695. The return value is ‘0’ on success and ‘-1’ on failure. The only
  3696. possible ‘errno’ error condition is ‘EFAULT’.
  3697. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  3698. 32-bit system this function is in fact ‘getrlimit64’. Thus, the
  3699. LFS interface transparently replaces the old interface.
  3700. -- Function: int getrlimit64 (int RESOURCE, struct rlimit64 *RLP)
  3701. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3702. Concepts::.
  3703. This function is similar to ‘getrlimit’ but its second parameter is
  3704. a pointer to a variable of type ‘struct rlimit64’, which allows it
  3705. to read values which wouldn’t fit in the member of a ‘struct
  3706. rlimit’.
  3707. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  3708. 32-bit machine, this function is available under the name
  3709. ‘getrlimit’ and so transparently replaces the old interface.
  3710. -- Function: int setrlimit (int RESOURCE, const struct rlimit *RLP)
  3711. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3712. Concepts::.
  3713. Store the current and maximum limits for the resource RESOURCE in
  3714. ‘*RLP’.
  3715. The return value is ‘0’ on success and ‘-1’ on failure. The
  3716. following ‘errno’ error condition is possible:
  3717. ‘EPERM’
  3718. • The process tried to raise a current limit beyond the
  3719. maximum limit.
  3720. • The process tried to raise a maximum limit, but is not
  3721. superuser.
  3722. When the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  3723. 32-bit system this function is in fact ‘setrlimit64’. Thus, the
  3724. LFS interface transparently replaces the old interface.
  3725. -- Function: int setrlimit64 (int RESOURCE, const struct rlimit64 *RLP)
  3726. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3727. Concepts::.
  3728. This function is similar to ‘setrlimit’ but its second parameter is
  3729. a pointer to a variable of type ‘struct rlimit64’ which allows it
  3730. to set values which wouldn’t fit in the member of a ‘struct
  3731. rlimit’.
  3732. If the sources are compiled with ‘_FILE_OFFSET_BITS == 64’ on a
  3733. 32-bit machine this function is available under the name
  3734. ‘setrlimit’ and so transparently replaces the old interface.
  3735. -- Data Type: struct rlimit
  3736. This structure is used with ‘getrlimit’ to receive limit values,
  3737. and with ‘setrlimit’ to specify limit values for a particular
  3738. process and resource. It has two fields:
  3739. ‘rlim_t rlim_cur’
  3740. The current limit
  3741. ‘rlim_t rlim_max’
  3742. The maximum limit.
  3743. For ‘getrlimit’, the structure is an output; it receives the
  3744. current values. For ‘setrlimit’, it specifies the new values.
  3745. For the LFS functions a similar type is defined in ‘sys/resource.h’.
  3746. -- Data Type: struct rlimit64
  3747. This structure is analogous to the ‘rlimit’ structure above, but
  3748. its components have wider ranges. It has two fields:
  3749. ‘rlim64_t rlim_cur’
  3750. This is analogous to ‘rlimit.rlim_cur’, but with a different
  3751. type.
  3752. ‘rlim64_t rlim_max’
  3753. This is analogous to ‘rlimit.rlim_max’, but with a different
  3754. type.
  3755. Here is a list of resources for which you can specify a limit.
  3756. Memory and file sizes are measured in bytes.
  3757. ‘RLIMIT_CPU’
  3758. The maximum amount of CPU time the process can use. If it runs for
  3759. longer than this, it gets a signal: ‘SIGXCPU’. The value is
  3760. measured in seconds. *Note Operation Error Signals::.
  3761. ‘RLIMIT_FSIZE’
  3762. The maximum size of file the process can create. Trying to write a
  3763. larger file causes a signal: ‘SIGXFSZ’. *Note Operation Error
  3764. Signals::.
  3765. ‘RLIMIT_DATA’
  3766. The maximum size of data memory for the process. If the process
  3767. tries to allocate data memory beyond this amount, the allocation
  3768. function fails.
  3769. ‘RLIMIT_STACK’
  3770. The maximum stack size for the process. If the process tries to
  3771. extend its stack past this size, it gets a ‘SIGSEGV’ signal. *Note
  3772. Program Error Signals::.
  3773. ‘RLIMIT_CORE’
  3774. The maximum size core file that this process can create. If the
  3775. process terminates and would dump a core file larger than this,
  3776. then no core file is created. So setting this limit to zero
  3777. prevents core files from ever being created.
  3778. ‘RLIMIT_RSS’
  3779. The maximum amount of physical memory that this process should get.
  3780. This parameter is a guide for the system’s scheduler and memory
  3781. allocator; the system may give the process more memory when there
  3782. is a surplus.
  3783. ‘RLIMIT_MEMLOCK’
  3784. The maximum amount of memory that can be locked into physical
  3785. memory (so it will never be paged out).
  3786. ‘RLIMIT_NPROC’
  3787. The maximum number of processes that can be created with the same
  3788. user ID. If you have reached the limit for your user ID, ‘fork’
  3789. will fail with ‘EAGAIN’. *Note Creating a Process::.
  3790. ‘RLIMIT_NOFILE’
  3791. ‘RLIMIT_OFILE’
  3792. The maximum number of files that the process can open. If it tries
  3793. to open more files than this, its open attempt fails with ‘errno’
  3794. ‘EMFILE’. *Note Error Codes::. Not all systems support this
  3795. limit; GNU does, and 4.4 BSD does.
  3796. ‘RLIMIT_AS’
  3797. The maximum size of total memory that this process should get. If
  3798. the process tries to allocate more memory beyond this amount with,
  3799. for example, ‘brk’, ‘malloc’, ‘mmap’ or ‘sbrk’, the allocation
  3800. function fails.
  3801. ‘RLIM_NLIMITS’
  3802. The number of different resource limits. Any valid RESOURCE
  3803. operand must be less than ‘RLIM_NLIMITS’.
  3804. -- Constant: rlim_t RLIM_INFINITY
  3805. This constant stands for a value of “infinity” when supplied as the
  3806. limit value in ‘setrlimit’.
  3807. The following are historical functions to do some of what the
  3808. functions above do. The functions above are better choices.
  3809. ‘ulimit’ and the command symbols are declared in ‘ulimit.h’.
  3810. -- Function: long int ulimit (int CMD, …)
  3811. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3812. Concepts::.
  3813. ‘ulimit’ gets the current limit or sets the current and maximum
  3814. limit for a particular resource for the calling process according
  3815. to the command CMD.
  3816. If you are getting a limit, the command argument is the only
  3817. argument. If you are setting a limit, there is a second argument:
  3818. ‘long int’ LIMIT which is the value to which you are setting the
  3819. limit.
  3820. The CMD values and the operations they specify are:
  3821. ‘GETFSIZE’
  3822. Get the current limit on the size of a file, in units of 512
  3823. bytes.
  3824. ‘SETFSIZE’
  3825. Set the current and maximum limit on the size of a file to
  3826. LIMIT * 512 bytes.
  3827. There are also some other CMD values that may do things on some
  3828. systems, but they are not supported.
  3829. Only the superuser may increase a maximum limit.
  3830. When you successfully get a limit, the return value of ‘ulimit’ is
  3831. that limit, which is never negative. When you successfully set a
  3832. limit, the return value is zero. When the function fails, the
  3833. return value is ‘-1’ and ‘errno’ is set according to the reason:
  3834. ‘EPERM’
  3835. A process tried to increase a maximum limit, but is not
  3836. superuser.
  3837. ‘vlimit’ and its resource symbols are declared in ‘sys/vlimit.h’.
  3838. -- Function: int vlimit (int RESOURCE, int LIMIT)
  3839. Preliminary: | MT-Unsafe race:setrlimit | AS-Unsafe | AC-Safe |
  3840. *Note POSIX Safety Concepts::.
  3841. ‘vlimit’ sets the current limit for a resource for a process.
  3842. RESOURCE identifies the resource:
  3843. ‘LIM_CPU’
  3844. Maximum CPU time. Same as ‘RLIMIT_CPU’ for ‘setrlimit’.
  3845. ‘LIM_FSIZE’
  3846. Maximum file size. Same as ‘RLIMIT_FSIZE’ for ‘setrlimit’.
  3847. ‘LIM_DATA’
  3848. Maximum data memory. Same as ‘RLIMIT_DATA’ for ‘setrlimit’.
  3849. ‘LIM_STACK’
  3850. Maximum stack size. Same as ‘RLIMIT_STACK’ for ‘setrlimit’.
  3851. ‘LIM_CORE’
  3852. Maximum core file size. Same as ‘RLIMIT_COR’ for ‘setrlimit’.
  3853. ‘LIM_MAXRSS’
  3854. Maximum physical memory. Same as ‘RLIMIT_RSS’ for
  3855. ‘setrlimit’.
  3856. The return value is zero for success, and ‘-1’ with ‘errno’ set
  3857. accordingly for failure:
  3858. ‘EPERM’
  3859. The process tried to set its current limit beyond its maximum
  3860. limit.
  3861. 
  3862. File: libc.info, Node: Priority, Next: Memory Resources, Prev: Limits on Resources, Up: Resource Usage And Limitation
  3863. 22.3 Process CPU Priority And Scheduling
  3864. ========================================
  3865. When multiple processes simultaneously require CPU time, the system’s
  3866. scheduling policy and process CPU priorities determine which processes
  3867. get it. This section describes how that determination is made and GNU C
  3868. Library functions to control it.
  3869. It is common to refer to CPU scheduling simply as scheduling and a
  3870. process’ CPU priority simply as the process’ priority, with the CPU
  3871. resource being implied. Bear in mind, though, that CPU time is not the
  3872. only resource a process uses or that processes contend for. In some
  3873. cases, it is not even particularly important. Giving a process a high
  3874. “priority” may have very little effect on how fast a process runs with
  3875. respect to other processes. The priorities discussed in this section
  3876. apply only to CPU time.
  3877. CPU scheduling is a complex issue and different systems do it in
  3878. wildly different ways. New ideas continually develop and find their way
  3879. into the intricacies of the various systems’ scheduling algorithms.
  3880. This section discusses the general concepts, some specifics of systems
  3881. that commonly use the GNU C Library, and some standards.
  3882. For simplicity, we talk about CPU contention as if there is only one
  3883. CPU in the system. But all the same principles apply when a processor
  3884. has multiple CPUs, and knowing that the number of processes that can run
  3885. at any one time is equal to the number of CPUs, you can easily
  3886. extrapolate the information.
  3887. The functions described in this section are all defined by the
  3888. POSIX.1 and POSIX.1b standards (the ‘sched…’ functions are POSIX.1b).
  3889. However, POSIX does not define any semantics for the values that these
  3890. functions get and set. In this chapter, the semantics are based on the
  3891. Linux kernel’s implementation of the POSIX standard. As you will see,
  3892. the Linux implementation is quite the inverse of what the authors of the
  3893. POSIX syntax had in mind.
  3894. * Menu:
  3895. * Absolute Priority:: The first tier of priority. Posix
  3896. * Realtime Scheduling:: Scheduling among the process nobility
  3897. * Basic Scheduling Functions:: Get/set scheduling policy, priority
  3898. * Traditional Scheduling:: Scheduling among the vulgar masses
  3899. * CPU Affinity:: Limiting execution to certain CPUs
  3900. 
  3901. File: libc.info, Node: Absolute Priority, Next: Realtime Scheduling, Up: Priority
  3902. 22.3.1 Absolute Priority
  3903. ------------------------
  3904. Every process has an absolute priority, and it is represented by a
  3905. number. The higher the number, the higher the absolute priority.
  3906. On systems of the past, and most systems today, all processes have
  3907. absolute priority 0 and this section is irrelevant. In that case, *Note
  3908. Traditional Scheduling::. Absolute priorities were invented to
  3909. accommodate realtime systems, in which it is vital that certain
  3910. processes be able to respond to external events happening in real time,
  3911. which means they cannot wait around while some other process that _wants
  3912. to_, but doesn’t _need to_ run occupies the CPU.
  3913. When two processes are in contention to use the CPU at any instant,
  3914. the one with the higher absolute priority always gets it. This is true
  3915. even if the process with the lower priority is already using the CPU
  3916. (i.e., the scheduling is preemptive). Of course, we’re only talking
  3917. about processes that are running or “ready to run,” which means they are
  3918. ready to execute instructions right now. When a process blocks to wait
  3919. for something like I/O, its absolute priority is irrelevant.
  3920. *NB:* The term “runnable” is a synonym for “ready to run.”
  3921. When two processes are running or ready to run and both have the same
  3922. absolute priority, it’s more interesting. In that case, who gets the
  3923. CPU is determined by the scheduling policy. If the processes have
  3924. absolute priority 0, the traditional scheduling policy described in
  3925. *note Traditional Scheduling:: applies. Otherwise, the policies
  3926. described in *note Realtime Scheduling:: apply.
  3927. You normally give an absolute priority above 0 only to a process that
  3928. can be trusted not to hog the CPU. Such processes are designed to block
  3929. (or terminate) after relatively short CPU runs.
  3930. A process begins life with the same absolute priority as its parent
  3931. process. Functions described in *note Basic Scheduling Functions:: can
  3932. change it.
  3933. Only a privileged process can change a process’ absolute priority to
  3934. something other than ‘0’. Only a privileged process or the target
  3935. process’ owner can change its absolute priority at all.
  3936. POSIX requires absolute priority values used with the realtime
  3937. scheduling policies to be consecutive with a range of at least 32. On
  3938. Linux, they are 1 through 99. The functions ‘sched_get_priority_max’
  3939. and ‘sched_set_priority_min’ portably tell you what the range is on a
  3940. particular system.
  3941. 22.3.1.1 Using Absolute Priority
  3942. ................................
  3943. One thing you must keep in mind when designing real time applications is
  3944. that having higher absolute priority than any other process doesn’t
  3945. guarantee the process can run continuously. Two things that can wreck a
  3946. good CPU run are interrupts and page faults.
  3947. Interrupt handlers live in that limbo between processes. The CPU is
  3948. executing instructions, but they aren’t part of any process. An
  3949. interrupt will stop even the highest priority process. So you must
  3950. allow for slight delays and make sure that no device in the system has
  3951. an interrupt handler that could cause too long a delay between
  3952. instructions for your process.
  3953. Similarly, a page fault causes what looks like a straightforward
  3954. sequence of instructions to take a long time. The fact that other
  3955. processes get to run while the page faults in is of no consequence,
  3956. because as soon as the I/O is complete, the higher priority process will
  3957. kick them out and run again, but the wait for the I/O itself could be a
  3958. problem. To neutralize this threat, use ‘mlock’ or ‘mlockall’.
  3959. There are a few ramifications of the absoluteness of this priority on
  3960. a single-CPU system that you need to keep in mind when you choose to set
  3961. a priority and also when you’re working on a program that runs with high
  3962. absolute priority. Consider a process that has higher absolute priority
  3963. than any other process in the system and due to a bug in its program, it
  3964. gets into an infinite loop. It will never cede the CPU. You can’t run a
  3965. command to kill it because your command would need to get the CPU in
  3966. order to run. The errant program is in complete control. It controls
  3967. the vertical, it controls the horizontal.
  3968. There are two ways to avoid this: 1) keep a shell running somewhere
  3969. with a higher absolute priority or 2) keep a controlling terminal
  3970. attached to the high priority process group. All the priority in the
  3971. world won’t stop an interrupt handler from running and delivering a
  3972. signal to the process if you hit Control-C.
  3973. Some systems use absolute priority as a means of allocating a fixed
  3974. percentage of CPU time to a process. To do this, a super high priority
  3975. privileged process constantly monitors the process’ CPU usage and raises
  3976. its absolute priority when the process isn’t getting its entitled share
  3977. and lowers it when the process is exceeding it.
  3978. *NB:* The absolute priority is sometimes called the “static
  3979. priority.” We don’t use that term in this manual because it misses the
  3980. most important feature of the absolute priority: its absoluteness.
  3981. 
  3982. File: libc.info, Node: Realtime Scheduling, Next: Basic Scheduling Functions, Prev: Absolute Priority, Up: Priority
  3983. 22.3.2 Realtime Scheduling
  3984. --------------------------
  3985. Whenever two processes with the same absolute priority are ready to run,
  3986. the kernel has a decision to make, because only one can run at a time.
  3987. If the processes have absolute priority 0, the kernel makes this
  3988. decision as described in *note Traditional Scheduling::. Otherwise, the
  3989. decision is as described in this section.
  3990. If two processes are ready to run but have different absolute
  3991. priorities, the decision is much simpler, and is described in *note
  3992. Absolute Priority::.
  3993. Each process has a scheduling policy. For processes with absolute
  3994. priority other than zero, there are two available:
  3995. 1. First Come First Served
  3996. 2. Round Robin
  3997. The most sensible case is where all the processes with a certain
  3998. absolute priority have the same scheduling policy. We’ll discuss that
  3999. first.
  4000. In Round Robin, processes share the CPU, each one running for a small
  4001. quantum of time (“time slice”) and then yielding to another in a
  4002. circular fashion. Of course, only processes that are ready to run and
  4003. have the same absolute priority are in this circle.
  4004. In First Come First Served, the process that has been waiting the
  4005. longest to run gets the CPU, and it keeps it until it voluntarily
  4006. relinquishes the CPU, runs out of things to do (blocks), or gets
  4007. preempted by a higher priority process.
  4008. First Come First Served, along with maximal absolute priority and
  4009. careful control of interrupts and page faults, is the one to use when a
  4010. process absolutely, positively has to run at full CPU speed or not at
  4011. all.
  4012. Judicious use of ‘sched_yield’ function invocations by processes with
  4013. First Come First Served scheduling policy forms a good compromise
  4014. between Round Robin and First Come First Served.
  4015. To understand how scheduling works when processes of different
  4016. scheduling policies occupy the same absolute priority, you have to know
  4017. the nitty gritty details of how processes enter and exit the ready to
  4018. run list.
  4019. In both cases, the ready to run list is organized as a true queue,
  4020. where a process gets pushed onto the tail when it becomes ready to run
  4021. and is popped off the head when the scheduler decides to run it. Note
  4022. that ready to run and running are two mutually exclusive states. When
  4023. the scheduler runs a process, that process is no longer ready to run and
  4024. no longer in the ready to run list. When the process stops running, it
  4025. may go back to being ready to run again.
  4026. The only difference between a process that is assigned the Round
  4027. Robin scheduling policy and a process that is assigned First Come First
  4028. Serve is that in the former case, the process is automatically booted
  4029. off the CPU after a certain amount of time. When that happens, the
  4030. process goes back to being ready to run, which means it enters the queue
  4031. at the tail. The time quantum we’re talking about is small. Really
  4032. small. This is not your father’s timesharing. For example, with the
  4033. Linux kernel, the round robin time slice is a thousand times shorter
  4034. than its typical time slice for traditional scheduling.
  4035. A process begins life with the same scheduling policy as its parent
  4036. process. Functions described in *note Basic Scheduling Functions:: can
  4037. change it.
  4038. Only a privileged process can set the scheduling policy of a process
  4039. that has absolute priority higher than 0.
  4040. 
  4041. File: libc.info, Node: Basic Scheduling Functions, Next: Traditional Scheduling, Prev: Realtime Scheduling, Up: Priority
  4042. 22.3.3 Basic Scheduling Functions
  4043. ---------------------------------
  4044. This section describes functions in the GNU C Library for setting the
  4045. absolute priority and scheduling policy of a process.
  4046. *Portability Note:* On systems that have the functions in this
  4047. section, the macro _POSIX_PRIORITY_SCHEDULING is defined in
  4048. ‘<unistd.h>’.
  4049. For the case that the scheduling policy is traditional scheduling,
  4050. more functions to fine tune the scheduling are in *note Traditional
  4051. Scheduling::.
  4052. Don’t try to make too much out of the naming and structure of these
  4053. functions. They don’t match the concepts described in this manual
  4054. because the functions are as defined by POSIX.1b, but the implementation
  4055. on systems that use the GNU C Library is the inverse of what the POSIX
  4056. structure contemplates. The POSIX scheme assumes that the primary
  4057. scheduling parameter is the scheduling policy and that the priority
  4058. value, if any, is a parameter of the scheduling policy. In the
  4059. implementation, though, the priority value is king and the scheduling
  4060. policy, if anything, only fine tunes the effect of that priority.
  4061. The symbols in this section are declared by including file ‘sched.h’.
  4062. -- Data Type: struct sched_param
  4063. This structure describes an absolute priority.
  4064. ‘int sched_priority’
  4065. absolute priority value
  4066. -- Function: int sched_setscheduler (pid_t PID, int POLICY, const
  4067. struct sched_param *PARAM)
  4068. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4069. Concepts::.
  4070. This function sets both the absolute priority and the scheduling
  4071. policy for a process.
  4072. It assigns the absolute priority value given by PARAM and the
  4073. scheduling policy POLICY to the process with Process ID PID, or the
  4074. calling process if PID is zero. If POLICY is negative,
  4075. ‘sched_setscheduler’ keeps the existing scheduling policy.
  4076. The following macros represent the valid values for POLICY:
  4077. ‘SCHED_OTHER’
  4078. Traditional Scheduling
  4079. ‘SCHED_FIFO’
  4080. First In First Out
  4081. ‘SCHED_RR’
  4082. Round Robin
  4083. On success, the return value is ‘0’. Otherwise, it is ‘-1’ and
  4084. ‘ERRNO’ is set accordingly. The ‘errno’ values specific to this
  4085. function are:
  4086. ‘EPERM’
  4087. • The calling process does not have ‘CAP_SYS_NICE’
  4088. permission and POLICY is not ‘SCHED_OTHER’ (or it’s
  4089. negative and the existing policy is not ‘SCHED_OTHER’.
  4090. • The calling process does not have ‘CAP_SYS_NICE’
  4091. permission and its owner is not the target process’
  4092. owner. I.e., the effective uid of the calling process is
  4093. neither the effective nor the real uid of process PID.
  4094. ‘ESRCH’
  4095. There is no process with pid PID and PID is not zero.
  4096. ‘EINVAL’
  4097. • POLICY does not identify an existing scheduling policy.
  4098. • The absolute priority value identified by *PARAM is
  4099. outside the valid range for the scheduling policy POLICY
  4100. (or the existing scheduling policy if POLICY is negative)
  4101. or PARAM is null. ‘sched_get_priority_max’ and
  4102. ‘sched_get_priority_min’ tell you what the valid range
  4103. is.
  4104. • PID is negative.
  4105. -- Function: int sched_getscheduler (pid_t PID)
  4106. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4107. Concepts::.
  4108. This function returns the scheduling policy assigned to the process
  4109. with Process ID (pid) PID, or the calling process if PID is zero.
  4110. The return value is the scheduling policy. See
  4111. ‘sched_setscheduler’ for the possible values.
  4112. If the function fails, the return value is instead ‘-1’ and ‘errno’
  4113. is set accordingly.
  4114. The ‘errno’ values specific to this function are:
  4115. ‘ESRCH’
  4116. There is no process with pid PID and it is not zero.
  4117. ‘EINVAL’
  4118. PID is negative.
  4119. Note that this function is not an exact mate to
  4120. ‘sched_setscheduler’ because while that function sets the
  4121. scheduling policy and the absolute priority, this function gets
  4122. only the scheduling policy. To get the absolute priority, use
  4123. ‘sched_getparam’.
  4124. -- Function: int sched_setparam (pid_t PID, const struct sched_param
  4125. *PARAM)
  4126. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4127. Concepts::.
  4128. This function sets a process’ absolute priority.
  4129. It is functionally identical to ‘sched_setscheduler’ with POLICY =
  4130. ‘-1’.
  4131. -- Function: int sched_getparam (pid_t PID, struct sched_param *PARAM)
  4132. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4133. Concepts::.
  4134. This function returns a process’ absolute priority.
  4135. PID is the Process ID (pid) of the process whose absolute priority
  4136. you want to know.
  4137. PARAM is a pointer to a structure in which the function stores the
  4138. absolute priority of the process.
  4139. On success, the return value is ‘0’. Otherwise, it is ‘-1’ and
  4140. ‘errno’ is set accordingly. The ‘errno’ values specific to this
  4141. function are:
  4142. ‘ESRCH’
  4143. There is no process with pid PID and it is not zero.
  4144. ‘EINVAL’
  4145. PID is negative.
  4146. -- Function: int sched_get_priority_min (int POLICY)
  4147. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4148. Concepts::.
  4149. This function returns the lowest absolute priority value that is
  4150. allowable for a process with scheduling policy POLICY.
  4151. On Linux, it is 0 for SCHED_OTHER and 1 for everything else.
  4152. On success, the return value is ‘0’. Otherwise, it is ‘-1’ and
  4153. ‘ERRNO’ is set accordingly. The ‘errno’ values specific to this
  4154. function are:
  4155. ‘EINVAL’
  4156. POLICY does not identify an existing scheduling policy.
  4157. -- Function: int sched_get_priority_max (int POLICY)
  4158. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4159. Concepts::.
  4160. This function returns the highest absolute priority value that is
  4161. allowable for a process that with scheduling policy POLICY.
  4162. On Linux, it is 0 for SCHED_OTHER and 99 for everything else.
  4163. On success, the return value is ‘0’. Otherwise, it is ‘-1’ and
  4164. ‘ERRNO’ is set accordingly. The ‘errno’ values specific to this
  4165. function are:
  4166. ‘EINVAL’
  4167. POLICY does not identify an existing scheduling policy.
  4168. -- Function: int sched_rr_get_interval (pid_t PID, struct timespec
  4169. *INTERVAL)
  4170. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4171. Concepts::.
  4172. This function returns the length of the quantum (time slice) used
  4173. with the Round Robin scheduling policy, if it is used, for the
  4174. process with Process ID PID.
  4175. It returns the length of time as INTERVAL.
  4176. With a Linux kernel, the round robin time slice is always 150
  4177. microseconds, and PID need not even be a real pid.
  4178. The return value is ‘0’ on success and in the pathological case
  4179. that it fails, the return value is ‘-1’ and ‘errno’ is set
  4180. accordingly. There is nothing specific that can go wrong with this
  4181. function, so there are no specific ‘errno’ values.
  4182. -- Function: int sched_yield (void)
  4183. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4184. Concepts::.
  4185. This function voluntarily gives up the process’ claim on the CPU.
  4186. Technically, ‘sched_yield’ causes the calling process to be made
  4187. immediately ready to run (as opposed to running, which is what it
  4188. was before). This means that if it has absolute priority higher
  4189. than 0, it gets pushed onto the tail of the queue of processes that
  4190. share its absolute priority and are ready to run, and it will run
  4191. again when its turn next arrives. If its absolute priority is 0,
  4192. it is more complicated, but still has the effect of yielding the
  4193. CPU to other processes.
  4194. If there are no other processes that share the calling process’
  4195. absolute priority, this function doesn’t have any effect.
  4196. To the extent that the containing program is oblivious to what
  4197. other processes in the system are doing and how fast it executes,
  4198. this function appears as a no-op.
  4199. The return value is ‘0’ on success and in the pathological case
  4200. that it fails, the return value is ‘-1’ and ‘errno’ is set
  4201. accordingly. There is nothing specific that can go wrong with this
  4202. function, so there are no specific ‘errno’ values.
  4203. 
  4204. File: libc.info, Node: Traditional Scheduling, Next: CPU Affinity, Prev: Basic Scheduling Functions, Up: Priority
  4205. 22.3.4 Traditional Scheduling
  4206. -----------------------------
  4207. This section is about the scheduling among processes whose absolute
  4208. priority is 0. When the system hands out the scraps of CPU time that
  4209. are left over after the processes with higher absolute priority have
  4210. taken all they want, the scheduling described herein determines who
  4211. among the great unwashed processes gets them.
  4212. * Menu:
  4213. * Traditional Scheduling Intro::
  4214. * Traditional Scheduling Functions::
  4215. 
  4216. File: libc.info, Node: Traditional Scheduling Intro, Next: Traditional Scheduling Functions, Up: Traditional Scheduling
  4217. 22.3.4.1 Introduction To Traditional Scheduling
  4218. ...............................................
  4219. Long before there was absolute priority (See *note Absolute Priority::),
  4220. Unix systems were scheduling the CPU using this system. When POSIX came
  4221. in like the Romans and imposed absolute priorities to accommodate the
  4222. needs of realtime processing, it left the indigenous Absolute Priority
  4223. Zero processes to govern themselves by their own familiar scheduling
  4224. policy.
  4225. Indeed, absolute priorities higher than zero are not available on
  4226. many systems today and are not typically used when they are, being
  4227. intended mainly for computers that do realtime processing. So this
  4228. section describes the only scheduling many programmers need to be
  4229. concerned about.
  4230. But just to be clear about the scope of this scheduling: Any time a
  4231. process with an absolute priority of 0 and a process with an absolute
  4232. priority higher than 0 are ready to run at the same time, the one with
  4233. absolute priority 0 does not run. If it’s already running when the
  4234. higher priority ready-to-run process comes into existence, it stops
  4235. immediately.
  4236. In addition to its absolute priority of zero, every process has
  4237. another priority, which we will refer to as "dynamic priority" because
  4238. it changes over time. The dynamic priority is meaningless for processes
  4239. with an absolute priority higher than zero.
  4240. The dynamic priority sometimes determines who gets the next turn on
  4241. the CPU. Sometimes it determines how long turns last. Sometimes it
  4242. determines whether a process can kick another off the CPU.
  4243. In Linux, the value is a combination of these things, but mostly it
  4244. just determines the length of the time slice. The higher a process’
  4245. dynamic priority, the longer a shot it gets on the CPU when it gets one.
  4246. If it doesn’t use up its time slice before giving up the CPU to do
  4247. something like wait for I/O, it is favored for getting the CPU back when
  4248. it’s ready for it, to finish out its time slice. Other than that,
  4249. selection of processes for new time slices is basically round robin.
  4250. But the scheduler does throw a bone to the low priority processes: A
  4251. process’ dynamic priority rises every time it is snubbed in the
  4252. scheduling process. In Linux, even the fat kid gets to play.
  4253. The fluctuation of a process’ dynamic priority is regulated by
  4254. another value: The “nice” value. The nice value is an integer, usually
  4255. in the range -20 to 20, and represents an upper limit on a process’
  4256. dynamic priority. The higher the nice number, the lower that limit.
  4257. On a typical Linux system, for example, a process with a nice value
  4258. of 20 can get only 10 milliseconds on the CPU at a time, whereas a
  4259. process with a nice value of -20 can achieve a high enough priority to
  4260. get 400 milliseconds.
  4261. The idea of the nice value is deferential courtesy. In the
  4262. beginning, in the Unix garden of Eden, all processes shared equally in
  4263. the bounty of the computer system. But not all processes really need
  4264. the same share of CPU time, so the nice value gave a courteous process
  4265. the ability to refuse its equal share of CPU time that others might
  4266. prosper. Hence, the higher a process’ nice value, the nicer the process
  4267. is. (Then a snake came along and offered some process a negative nice
  4268. value and the system became the crass resource allocation system we know
  4269. today.)
  4270. Dynamic priorities tend upward and downward with an objective of
  4271. smoothing out allocation of CPU time and giving quick response time to
  4272. infrequent requests. But they never exceed their nice limits, so on a
  4273. heavily loaded CPU, the nice value effectively determines how fast a
  4274. process runs.
  4275. In keeping with the socialistic heritage of Unix process priority, a
  4276. process begins life with the same nice value as its parent process and
  4277. can raise it at will. A process can also raise the nice value of any
  4278. other process owned by the same user (or effective user). But only a
  4279. privileged process can lower its nice value. A privileged process can
  4280. also raise or lower another process’ nice value.
  4281. GNU C Library functions for getting and setting nice values are
  4282. described in *Note Traditional Scheduling Functions::.
  4283. 
  4284. File: libc.info, Node: Traditional Scheduling Functions, Prev: Traditional Scheduling Intro, Up: Traditional Scheduling
  4285. 22.3.4.2 Functions For Traditional Scheduling
  4286. .............................................
  4287. This section describes how you can read and set the nice value of a
  4288. process. All these symbols are declared in ‘sys/resource.h’.
  4289. The function and macro names are defined by POSIX, and refer to
  4290. "priority," but the functions actually have to do with nice values, as
  4291. the terms are used both in the manual and POSIX.
  4292. The range of valid nice values depends on the kernel, but typically
  4293. it runs from ‘-20’ to ‘20’. A lower nice value corresponds to higher
  4294. priority for the process. These constants describe the range of
  4295. priority values:
  4296. ‘PRIO_MIN’
  4297. The lowest valid nice value.
  4298. ‘PRIO_MAX’
  4299. The highest valid nice value.
  4300. -- Function: int getpriority (int CLASS, int ID)
  4301. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4302. Concepts::.
  4303. Return the nice value of a set of processes; CLASS and ID specify
  4304. which ones (see below). If the processes specified do not all have
  4305. the same nice value, this returns the lowest value that any of them
  4306. has.
  4307. On success, the return value is ‘0’. Otherwise, it is ‘-1’ and
  4308. ‘errno’ is set accordingly. The ‘errno’ values specific to this
  4309. function are:
  4310. ‘ESRCH’
  4311. The combination of CLASS and ID does not match any existing
  4312. process.
  4313. ‘EINVAL’
  4314. The value of CLASS is not valid.
  4315. If the return value is ‘-1’, it could indicate failure, or it could
  4316. be the nice value. The only way to make certain is to set ‘errno =
  4317. 0’ before calling ‘getpriority’, then use ‘errno != 0’ afterward as
  4318. the criterion for failure.
  4319. -- Function: int setpriority (int CLASS, int ID, int NICEVAL)
  4320. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4321. Concepts::.
  4322. Set the nice value of a set of processes to NICEVAL; CLASS and ID
  4323. specify which ones (see below).
  4324. The return value is ‘0’ on success, and ‘-1’ on failure. The
  4325. following ‘errno’ error condition are possible for this function:
  4326. ‘ESRCH’
  4327. The combination of CLASS and ID does not match any existing
  4328. process.
  4329. ‘EINVAL’
  4330. The value of CLASS is not valid.
  4331. ‘EPERM’
  4332. The call would set the nice value of a process which is owned
  4333. by a different user than the calling process (i.e., the target
  4334. process’ real or effective uid does not match the calling
  4335. process’ effective uid) and the calling process does not have
  4336. ‘CAP_SYS_NICE’ permission.
  4337. ‘EACCES’
  4338. The call would lower the process’ nice value and the process
  4339. does not have ‘CAP_SYS_NICE’ permission.
  4340. The arguments CLASS and ID together specify a set of processes in
  4341. which you are interested. These are the possible values of CLASS:
  4342. ‘PRIO_PROCESS’
  4343. One particular process. The argument ID is a process ID (pid).
  4344. ‘PRIO_PGRP’
  4345. All the processes in a particular process group. The argument ID
  4346. is a process group ID (pgid).
  4347. ‘PRIO_USER’
  4348. All the processes owned by a particular user (i.e., whose real uid
  4349. indicates the user). The argument ID is a user ID (uid).
  4350. If the argument ID is 0, it stands for the calling process, its
  4351. process group, or its owner (real uid), according to CLASS.
  4352. -- Function: int nice (int INCREMENT)
  4353. Preliminary: | MT-Unsafe race:setpriority | AS-Unsafe | AC-Safe |
  4354. *Note POSIX Safety Concepts::.
  4355. Increment the nice value of the calling process by INCREMENT. The
  4356. return value is the new nice value on success, and ‘-1’ on failure.
  4357. In the case of failure, ‘errno’ will be set to the same values as
  4358. for ‘setpriority’.
  4359. Here is an equivalent definition of ‘nice’:
  4360. int
  4361. nice (int increment)
  4362. {
  4363. int result, old = getpriority (PRIO_PROCESS, 0);
  4364. result = setpriority (PRIO_PROCESS, 0, old + increment);
  4365. if (result != -1)
  4366. return old + increment;
  4367. else
  4368. return -1;
  4369. }
  4370. 
  4371. File: libc.info, Node: CPU Affinity, Prev: Traditional Scheduling, Up: Priority
  4372. 22.3.5 Limiting execution to certain CPUs
  4373. -----------------------------------------
  4374. On a multi-processor system the operating system usually distributes the
  4375. different processes which are runnable on all available CPUs in a way
  4376. which allows the system to work most efficiently. Which processes and
  4377. threads run can be to some extend be control with the scheduling
  4378. functionality described in the last sections. But which CPU finally
  4379. executes which process or thread is not covered.
  4380. There are a number of reasons why a program might want to have
  4381. control over this aspect of the system as well:
  4382. • One thread or process is responsible for absolutely critical work
  4383. which under no circumstances must be interrupted or hindered from
  4384. making progress by other processes or threads using CPU resources.
  4385. In this case the special process would be confined to a CPU which
  4386. no other process or thread is allowed to use.
  4387. • The access to certain resources (RAM, I/O ports) has different
  4388. costs from different CPUs. This is the case in NUMA (Non-Uniform
  4389. Memory Architecture) machines. Preferably memory should be
  4390. accessed locally but this requirement is usually not visible to the
  4391. scheduler. Therefore forcing a process or thread to the CPUs which
  4392. have local access to the most-used memory helps to significantly
  4393. boost the performance.
  4394. • In controlled runtimes resource allocation and book-keeping work
  4395. (for instance garbage collection) is performance local to
  4396. processors. This can help to reduce locking costs if the resources
  4397. do not have to be protected from concurrent accesses from different
  4398. processors.
  4399. The POSIX standard up to this date is of not much help to solve this
  4400. problem. The Linux kernel provides a set of interfaces to allow
  4401. specifying _affinity sets_ for a process. The scheduler will schedule
  4402. the thread or process on CPUs specified by the affinity masks. The
  4403. interfaces which the GNU C Library define follow to some extent the
  4404. Linux kernel interface.
  4405. -- Data Type: cpu_set_t
  4406. This data set is a bitset where each bit represents a CPU. How the
  4407. system’s CPUs are mapped to bits in the bitset is system dependent.
  4408. The data type has a fixed size; in the unlikely case that the
  4409. number of bits are not sufficient to describe the CPUs of the
  4410. system a different interface has to be used.
  4411. This type is a GNU extension and is defined in ‘sched.h’.
  4412. To manipulate the bitset, to set and reset bits, a number of macros
  4413. are defined. Some of the macros take a CPU number as a parameter. Here
  4414. it is important to never exceed the size of the bitset. The following
  4415. macro specifies the number of bits in the ‘cpu_set_t’ bitset.
  4416. -- Macro: int CPU_SETSIZE
  4417. The value of this macro is the maximum number of CPUs which can be
  4418. handled with a ‘cpu_set_t’ object.
  4419. The type ‘cpu_set_t’ should be considered opaque; all manipulation
  4420. should happen via the next four macros.
  4421. -- Macro: void CPU_ZERO (cpu_set_t *SET)
  4422. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4423. Concepts::.
  4424. This macro initializes the CPU set SET to be the empty set.
  4425. This macro is a GNU extension and is defined in ‘sched.h’.
  4426. -- Macro: void CPU_SET (int CPU, cpu_set_t *SET)
  4427. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4428. Concepts::.
  4429. This macro adds CPU to the CPU set SET.
  4430. The CPU parameter must not have side effects since it is evaluated
  4431. more than once.
  4432. This macro is a GNU extension and is defined in ‘sched.h’.
  4433. -- Macro: void CPU_CLR (int CPU, cpu_set_t *SET)
  4434. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4435. Concepts::.
  4436. This macro removes CPU from the CPU set SET.
  4437. The CPU parameter must not have side effects since it is evaluated
  4438. more than once.
  4439. This macro is a GNU extension and is defined in ‘sched.h’.
  4440. -- Macro: int CPU_ISSET (int CPU, const cpu_set_t *SET)
  4441. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4442. Concepts::.
  4443. This macro returns a nonzero value (true) if CPU is a member of the
  4444. CPU set SET, and zero (false) otherwise.
  4445. The CPU parameter must not have side effects since it is evaluated
  4446. more than once.
  4447. This macro is a GNU extension and is defined in ‘sched.h’.
  4448. CPU bitsets can be constructed from scratch or the currently
  4449. installed affinity mask can be retrieved from the system.
  4450. -- Function: int sched_getaffinity (pid_t PID, size_t CPUSETSIZE,
  4451. cpu_set_t *CPUSET)
  4452. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4453. Concepts::.
  4454. This function stores the CPU affinity mask for the process or
  4455. thread with the ID PID in the CPUSETSIZE bytes long bitmap pointed
  4456. to by CPUSET. If successful, the function always initializes all
  4457. bits in the ‘cpu_set_t’ object and returns zero.
  4458. If PID does not correspond to a process or thread on the system the
  4459. or the function fails for some other reason, it returns ‘-1’ and
  4460. ‘errno’ is set to represent the error condition.
  4461. ‘ESRCH’
  4462. No process or thread with the given ID found.
  4463. ‘EFAULT’
  4464. The pointer CPUSET does not point to a valid object.
  4465. This function is a GNU extension and is declared in ‘sched.h’.
  4466. Note that it is not portably possible to use this information to
  4467. retrieve the information for different POSIX threads. A separate
  4468. interface must be provided for that.
  4469. -- Function: int sched_setaffinity (pid_t PID, size_t CPUSETSIZE, const
  4470. cpu_set_t *CPUSET)
  4471. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4472. Concepts::.
  4473. This function installs the CPUSETSIZE bytes long affinity mask
  4474. pointed to by CPUSET for the process or thread with the ID PID. If
  4475. successful the function returns zero and the scheduler will in the
  4476. future take the affinity information into account.
  4477. If the function fails it will return ‘-1’ and ‘errno’ is set to the
  4478. error code:
  4479. ‘ESRCH’
  4480. No process or thread with the given ID found.
  4481. ‘EFAULT’
  4482. The pointer CPUSET does not point to a valid object.
  4483. ‘EINVAL’
  4484. The bitset is not valid. This might mean that the affinity
  4485. set might not leave a processor for the process or thread to
  4486. run on.
  4487. This function is a GNU extension and is declared in ‘sched.h’.
  4488. 
  4489. File: libc.info, Node: Memory Resources, Next: Processor Resources, Prev: Priority, Up: Resource Usage And Limitation
  4490. 22.4 Querying memory available resources
  4491. ========================================
  4492. The amount of memory available in the system and the way it is organized
  4493. determines oftentimes the way programs can and have to work. For
  4494. functions like ‘mmap’ it is necessary to know about the size of
  4495. individual memory pages and knowing how much memory is available enables
  4496. a program to select appropriate sizes for, say, caches. Before we get
  4497. into these details a few words about memory subsystems in traditional
  4498. Unix systems will be given.
  4499. * Menu:
  4500. * Memory Subsystem:: Overview about traditional Unix memory handling.
  4501. * Query Memory Parameters:: How to get information about the memory
  4502. subsystem?
  4503. 
  4504. File: libc.info, Node: Memory Subsystem, Next: Query Memory Parameters, Up: Memory Resources
  4505. 22.4.1 Overview about traditional Unix memory handling
  4506. ------------------------------------------------------
  4507. Unix systems normally provide processes virtual address spaces. This
  4508. means that the addresses of the memory regions do not have to correspond
  4509. directly to the addresses of the actual physical memory which stores the
  4510. data. An extra level of indirection is introduced which translates
  4511. virtual addresses into physical addresses. This is normally done by the
  4512. hardware of the processor.
  4513. Using a virtual address space has several advantages. The most
  4514. important is process isolation. The different processes running on the
  4515. system cannot interfere directly with each other. No process can write
  4516. into the address space of another process (except when shared memory is
  4517. used but then it is wanted and controlled).
  4518. Another advantage of virtual memory is that the address space the
  4519. processes see can actually be larger than the physical memory available.
  4520. The physical memory can be extended by storage on an external media
  4521. where the content of currently unused memory regions is stored. The
  4522. address translation can then intercept accesses to these memory regions
  4523. and make memory content available again by loading the data back into
  4524. memory. This concept makes it necessary that programs which have to use
  4525. lots of memory know the difference between available virtual address
  4526. space and available physical memory. If the working set of virtual
  4527. memory of all the processes is larger than the available physical memory
  4528. the system will slow down dramatically due to constant swapping of
  4529. memory content from the memory to the storage media and back. This is
  4530. called “thrashing”.
  4531. A final aspect of virtual memory which is important and follows from
  4532. what is said in the last paragraph is the granularity of the virtual
  4533. address space handling. When we said that the virtual address handling
  4534. stores memory content externally it cannot do this on a byte-by-byte
  4535. basis. The administrative overhead does not allow this (leaving alone
  4536. the processor hardware). Instead several thousand bytes are handled
  4537. together and form a "page". The size of each page is always a power of
  4538. two bytes. The smallest page size in use today is 4096, with 8192,
  4539. 16384, and 65536 being other popular sizes.
  4540. 
  4541. File: libc.info, Node: Query Memory Parameters, Prev: Memory Subsystem, Up: Memory Resources
  4542. 22.4.2 How to get information about the memory subsystem?
  4543. ---------------------------------------------------------
  4544. The page size of the virtual memory the process sees is essential to
  4545. know in several situations. Some programming interfaces (e.g., ‘mmap’,
  4546. *note Memory-mapped I/O::) require the user to provide information
  4547. adjusted to the page size. In the case of ‘mmap’ it is necessary to
  4548. provide a length argument which is a multiple of the page size. Another
  4549. place where the knowledge about the page size is useful is in memory
  4550. allocation. If one allocates pieces of memory in larger chunks which
  4551. are then subdivided by the application code it is useful to adjust the
  4552. size of the larger blocks to the page size. If the total memory
  4553. requirement for the block is close (but not larger) to a multiple of the
  4554. page size the kernel’s memory handling can work more effectively since
  4555. it only has to allocate memory pages which are fully used. (To do this
  4556. optimization it is necessary to know a bit about the memory allocator
  4557. which will require a bit of memory itself for each block and this
  4558. overhead must not push the total size over the page size multiple.)
  4559. The page size traditionally was a compile time constant. But recent
  4560. development of processors changed this. Processors now support
  4561. different page sizes and they can possibly even vary among different
  4562. processes on the same system. Therefore the system should be queried at
  4563. runtime about the current page size and no assumptions (except about it
  4564. being a power of two) should be made.
  4565. The correct interface to query about the page size is ‘sysconf’
  4566. (*note Sysconf Definition::) with the parameter ‘_SC_PAGESIZE’. There
  4567. is a much older interface available, too.
  4568. -- Function: int getpagesize (void)
  4569. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4570. Concepts::.
  4571. The ‘getpagesize’ function returns the page size of the process.
  4572. This value is fixed for the runtime of the process but can vary in
  4573. different runs of the application.
  4574. The function is declared in ‘unistd.h’.
  4575. Widely available on System V derived systems is a method to get
  4576. information about the physical memory the system has. The call
  4577. sysconf (_SC_PHYS_PAGES)
  4578. returns the total number of pages of physical memory the system has.
  4579. This does not mean all this memory is available. This information can
  4580. be found using
  4581. sysconf (_SC_AVPHYS_PAGES)
  4582. These two values help to optimize applications. The value returned
  4583. for ‘_SC_AVPHYS_PAGES’ is the amount of memory the application can use
  4584. without hindering any other process (given that no other process
  4585. increases its memory usage). The value returned for ‘_SC_PHYS_PAGES’ is
  4586. more or less a hard limit for the working set. If all applications
  4587. together constantly use more than that amount of memory the system is in
  4588. trouble.
  4589. The GNU C Library provides in addition to these already described way
  4590. to get this information two functions. They are declared in the file
  4591. ‘sys/sysinfo.h’. Programmers should prefer to use the ‘sysconf’ method
  4592. described above.
  4593. -- Function: long int get_phys_pages (void)
  4594. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock fd
  4595. mem | *Note POSIX Safety Concepts::.
  4596. The ‘get_phys_pages’ function returns the total number of pages of
  4597. physical memory the system has. To get the amount of memory this
  4598. number has to be multiplied by the page size.
  4599. This function is a GNU extension.
  4600. -- Function: long int get_avphys_pages (void)
  4601. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock fd
  4602. mem | *Note POSIX Safety Concepts::.
  4603. The ‘get_avphys_pages’ function returns the number of available
  4604. pages of physical memory the system has. To get the amount of
  4605. memory this number has to be multiplied by the page size.
  4606. This function is a GNU extension.
  4607. 
  4608. File: libc.info, Node: Processor Resources, Prev: Memory Resources, Up: Resource Usage And Limitation
  4609. 22.5 Learn about the processors available
  4610. =========================================
  4611. The use of threads or processes with shared memory allows an application
  4612. to take advantage of all the processing power a system can provide. If
  4613. the task can be parallelized the optimal way to write an application is
  4614. to have at any time as many processes running as there are processors.
  4615. To determine the number of processors available to the system one can
  4616. run
  4617. sysconf (_SC_NPROCESSORS_CONF)
  4618. which returns the number of processors the operating system configured.
  4619. But it might be possible for the operating system to disable individual
  4620. processors and so the call
  4621. sysconf (_SC_NPROCESSORS_ONLN)
  4622. returns the number of processors which are currently online (i.e.,
  4623. available).
  4624. For these two pieces of information the GNU C Library also provides
  4625. functions to get the information directly. The functions are declared
  4626. in ‘sys/sysinfo.h’.
  4627. -- Function: int get_nprocs_conf (void)
  4628. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock fd
  4629. mem | *Note POSIX Safety Concepts::.
  4630. The ‘get_nprocs_conf’ function returns the number of processors the
  4631. operating system configured.
  4632. This function is a GNU extension.
  4633. -- Function: int get_nprocs (void)
  4634. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  4635. Concepts::.
  4636. The ‘get_nprocs’ function returns the number of available
  4637. processors.
  4638. This function is a GNU extension.
  4639. Before starting more threads it should be checked whether the
  4640. processors are not already overused. Unix systems calculate something
  4641. called the "load average". This is a number indicating how many
  4642. processes were running. This number is an average over different
  4643. periods of time (normally 1, 5, and 15 minutes).
  4644. -- Function: int getloadavg (double LOADAVG[], int NELEM)
  4645. Preliminary: | MT-Safe | AS-Safe | AC-Safe fd | *Note POSIX Safety
  4646. Concepts::.
  4647. This function gets the 1, 5 and 15 minute load averages of the
  4648. system. The values are placed in LOADAVG. ‘getloadavg’ will place
  4649. at most NELEM elements into the array but never more than three
  4650. elements. The return value is the number of elements written to
  4651. LOADAVG, or -1 on error.
  4652. This function is declared in ‘stdlib.h’.
  4653. 
  4654. File: libc.info, Node: Non-Local Exits, Next: Signal Handling, Prev: Resource Usage And Limitation, Up: Top
  4655. 23 Non-Local Exits
  4656. ******************
  4657. Sometimes when your program detects an unusual situation inside a deeply
  4658. nested set of function calls, you would like to be able to immediately
  4659. return to an outer level of control. This section describes how you can
  4660. do such "non-local exits" using the ‘setjmp’ and ‘longjmp’ functions.
  4661. * Menu:
  4662. * Intro: Non-Local Intro. When and how to use these facilities.
  4663. * Details: Non-Local Details. Functions for non-local exits.
  4664. * Non-Local Exits and Signals:: Portability issues.
  4665. * System V contexts:: Complete context control a la System V.
  4666. 
  4667. File: libc.info, Node: Non-Local Intro, Next: Non-Local Details, Up: Non-Local Exits
  4668. 23.1 Introduction to Non-Local Exits
  4669. ====================================
  4670. As an example of a situation where a non-local exit can be useful,
  4671. suppose you have an interactive program that has a “main loop” that
  4672. prompts for and executes commands. Suppose the “read” command reads
  4673. input from a file, doing some lexical analysis and parsing of the input
  4674. while processing it. If a low-level input error is detected, it would
  4675. be useful to be able to return immediately to the “main loop” instead of
  4676. having to make each of the lexical analysis, parsing, and processing
  4677. phases all have to explicitly deal with error situations initially
  4678. detected by nested calls.
  4679. (On the other hand, if each of these phases has to do a substantial
  4680. amount of cleanup when it exits—such as closing files, deallocating
  4681. buffers or other data structures, and the like—then it can be more
  4682. appropriate to do a normal return and have each phase do its own
  4683. cleanup, because a non-local exit would bypass the intervening phases
  4684. and their associated cleanup code entirely. Alternatively, you could
  4685. use a non-local exit but do the cleanup explicitly either before or
  4686. after returning to the “main loop”.)
  4687. In some ways, a non-local exit is similar to using the ‘return’
  4688. statement to return from a function. But while ‘return’ abandons only a
  4689. single function call, transferring control back to the point at which it
  4690. was called, a non-local exit can potentially abandon many levels of
  4691. nested function calls.
  4692. You identify return points for non-local exits by calling the
  4693. function ‘setjmp’. This function saves information about the execution
  4694. environment in which the call to ‘setjmp’ appears in an object of type
  4695. ‘jmp_buf’. Execution of the program continues normally after the call
  4696. to ‘setjmp’, but if an exit is later made to this return point by
  4697. calling ‘longjmp’ with the corresponding ‘jmp_buf’ object, control is
  4698. transferred back to the point where ‘setjmp’ was called. The return
  4699. value from ‘setjmp’ is used to distinguish between an ordinary return
  4700. and a return made by a call to ‘longjmp’, so calls to ‘setjmp’ usually
  4701. appear in an ‘if’ statement.
  4702. Here is how the example program described above might be set up:
  4703. #include <setjmp.h>
  4704. #include <stdlib.h>
  4705. #include <stdio.h>
  4706. jmp_buf main_loop;
  4707. void
  4708. abort_to_main_loop (int status)
  4709. {
  4710. longjmp (main_loop, status);
  4711. }
  4712. int
  4713. main (void)
  4714. {
  4715. while (1)
  4716. if (setjmp (main_loop))
  4717. puts ("Back at main loop....");
  4718. else
  4719. do_command ();
  4720. }
  4721. void
  4722. do_command (void)
  4723. {
  4724. char buffer[128];
  4725. if (fgets (buffer, 128, stdin) == NULL)
  4726. abort_to_main_loop (-1);
  4727. else
  4728. exit (EXIT_SUCCESS);
  4729. }
  4730. The function ‘abort_to_main_loop’ causes an immediate transfer of
  4731. control back to the main loop of the program, no matter where it is
  4732. called from.
  4733. The flow of control inside the ‘main’ function may appear a little
  4734. mysterious at first, but it is actually a common idiom with ‘setjmp’. A
  4735. normal call to ‘setjmp’ returns zero, so the “else” clause of the
  4736. conditional is executed. If ‘abort_to_main_loop’ is called somewhere
  4737. within the execution of ‘do_command’, then it actually appears as if the
  4738. _same_ call to ‘setjmp’ in ‘main’ were returning a second time with a
  4739. value of ‘-1’.
  4740. So, the general pattern for using ‘setjmp’ looks something like:
  4741. if (setjmp (BUFFER))
  4742. /* Code to clean up after premature return. */
  4743. else
  4744. /* Code to be executed normally after setting up the return point. */
  4745. 
  4746. File: libc.info, Node: Non-Local Details, Next: Non-Local Exits and Signals, Prev: Non-Local Intro, Up: Non-Local Exits
  4747. 23.2 Details of Non-Local Exits
  4748. ===============================
  4749. Here are the details on the functions and data structures used for
  4750. performing non-local exits. These facilities are declared in
  4751. ‘setjmp.h’.
  4752. -- Data Type: jmp_buf
  4753. Objects of type ‘jmp_buf’ hold the state information to be restored
  4754. by a non-local exit. The contents of a ‘jmp_buf’ identify a
  4755. specific place to return to.
  4756. -- Macro: int setjmp (jmp_buf STATE)
  4757. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4758. Concepts::.
  4759. When called normally, ‘setjmp’ stores information about the
  4760. execution state of the program in STATE and returns zero. If
  4761. ‘longjmp’ is later used to perform a non-local exit to this STATE,
  4762. ‘setjmp’ returns a nonzero value.
  4763. -- Function: void longjmp (jmp_buf STATE, int VALUE)
  4764. Preliminary: | MT-Safe | AS-Unsafe plugin corrupt lock/hurd |
  4765. AC-Unsafe corrupt lock/hurd | *Note POSIX Safety Concepts::.
  4766. This function restores current execution to the state saved in
  4767. STATE, and continues execution from the call to ‘setjmp’ that
  4768. established that return point. Returning from ‘setjmp’ by means of
  4769. ‘longjmp’ returns the VALUE argument that was passed to ‘longjmp’,
  4770. rather than ‘0’. (But if VALUE is given as ‘0’, ‘setjmp’ returns
  4771. ‘1’).
  4772. There are a lot of obscure but important restrictions on the use of
  4773. ‘setjmp’ and ‘longjmp’. Most of these restrictions are present because
  4774. non-local exits require a fair amount of magic on the part of the C
  4775. compiler and can interact with other parts of the language in strange
  4776. ways.
  4777. The ‘setjmp’ function is actually a macro without an actual function
  4778. definition, so you shouldn’t try to ‘#undef’ it or take its address. In
  4779. addition, calls to ‘setjmp’ are safe in only the following contexts:
  4780. • As the test expression of a selection or iteration statement (such
  4781. as ‘if’, ‘switch’, or ‘while’).
  4782. • As one operand of an equality or comparison operator that appears
  4783. as the test expression of a selection or iteration statement. The
  4784. other operand must be an integer constant expression.
  4785. • As the operand of a unary ‘!’ operator, that appears as the test
  4786. expression of a selection or iteration statement.
  4787. • By itself as an expression statement.
  4788. Return points are valid only during the dynamic extent of the
  4789. function that called ‘setjmp’ to establish them. If you ‘longjmp’ to a
  4790. return point that was established in a function that has already
  4791. returned, unpredictable and disastrous things are likely to happen.
  4792. You should use a nonzero VALUE argument to ‘longjmp’. While
  4793. ‘longjmp’ refuses to pass back a zero argument as the return value from
  4794. ‘setjmp’, this is intended as a safety net against accidental misuse and
  4795. is not really good programming style.
  4796. When you perform a non-local exit, accessible objects generally
  4797. retain whatever values they had at the time ‘longjmp’ was called. The
  4798. exception is that the values of automatic variables local to the
  4799. function containing the ‘setjmp’ call that have been changed since the
  4800. call to ‘setjmp’ are indeterminate, unless you have declared them
  4801. ‘volatile’.
  4802. 
  4803. File: libc.info, Node: Non-Local Exits and Signals, Next: System V contexts, Prev: Non-Local Details, Up: Non-Local Exits
  4804. 23.3 Non-Local Exits and Signals
  4805. ================================
  4806. In BSD Unix systems, ‘setjmp’ and ‘longjmp’ also save and restore the
  4807. set of blocked signals; see *note Blocking Signals::. However, the
  4808. POSIX.1 standard requires ‘setjmp’ and ‘longjmp’ not to change the set
  4809. of blocked signals, and provides an additional pair of functions
  4810. (‘sigsetjmp’ and ‘siglongjmp’) to get the BSD behavior.
  4811. The behavior of ‘setjmp’ and ‘longjmp’ in the GNU C Library is
  4812. controlled by feature test macros; see *note Feature Test Macros::. The
  4813. default in the GNU C Library is the POSIX.1 behavior rather than the BSD
  4814. behavior.
  4815. The facilities in this section are declared in the header file
  4816. ‘setjmp.h’.
  4817. -- Data Type: sigjmp_buf
  4818. This is similar to ‘jmp_buf’, except that it can also store state
  4819. information about the set of blocked signals.
  4820. -- Function: int sigsetjmp (sigjmp_buf STATE, int SAVESIGS)
  4821. Preliminary: | MT-Safe | AS-Unsafe lock/hurd | AC-Unsafe lock/hurd
  4822. | *Note POSIX Safety Concepts::.
  4823. This is similar to ‘setjmp’. If SAVESIGS is nonzero, the set of
  4824. blocked signals is saved in STATE and will be restored if a
  4825. ‘siglongjmp’ is later performed with this STATE.
  4826. -- Function: void siglongjmp (sigjmp_buf STATE, int VALUE)
  4827. Preliminary: | MT-Safe | AS-Unsafe plugin corrupt lock/hurd |
  4828. AC-Unsafe corrupt lock/hurd | *Note POSIX Safety Concepts::.
  4829. This is similar to ‘longjmp’ except for the type of its STATE
  4830. argument. If the ‘sigsetjmp’ call that set this STATE used a
  4831. nonzero SAVESIGS flag, ‘siglongjmp’ also restores the set of
  4832. blocked signals.
  4833. 
  4834. File: libc.info, Node: System V contexts, Prev: Non-Local Exits and Signals, Up: Non-Local Exits
  4835. 23.4 Complete Context Control
  4836. =============================
  4837. The Unix standard provides one more set of functions to control the
  4838. execution path and these functions are more powerful than those
  4839. discussed in this chapter so far. These functions were part of the
  4840. original System V API and by this route were added to the Unix API.
  4841. Besides on branded Unix implementations these interfaces are not widely
  4842. available. Not all platforms and/or architectures the GNU C Library is
  4843. available on provide this interface. Use ‘configure’ to detect the
  4844. availability.
  4845. Similar to the ‘jmp_buf’ and ‘sigjmp_buf’ types used for the
  4846. variables to contain the state of the ‘longjmp’ functions the interfaces
  4847. of interest here have an appropriate type as well. Objects of this type
  4848. are normally much larger since more information is contained. The type
  4849. is also used in a few more places as we will see. The types and
  4850. functions described in this section are all defined and declared
  4851. respectively in the ‘ucontext.h’ header file.
  4852. -- Data Type: ucontext_t
  4853. The ‘ucontext_t’ type is defined as a structure with at least the
  4854. following elements:
  4855. ‘ucontext_t *uc_link’
  4856. This is a pointer to the next context structure which is used
  4857. if the context described in the current structure returns.
  4858. ‘sigset_t uc_sigmask’
  4859. Set of signals which are blocked when this context is used.
  4860. ‘stack_t uc_stack’
  4861. Stack used for this context. The value need not be (and
  4862. normally is not) the stack pointer. *Note Signal Stack::.
  4863. ‘mcontext_t uc_mcontext’
  4864. This element contains the actual state of the process. The
  4865. ‘mcontext_t’ type is also defined in this header but the
  4866. definition should be treated as opaque. Any use of knowledge
  4867. of the type makes applications less portable.
  4868. Objects of this type have to be created by the user. The
  4869. initialization and modification happens through one of the following
  4870. functions:
  4871. -- Function: int getcontext (ucontext_t *UCP)
  4872. Preliminary: | MT-Safe race:ucp | AS-Safe | AC-Safe | *Note POSIX
  4873. Safety Concepts::.
  4874. The ‘getcontext’ function initializes the variable pointed to by
  4875. UCP with the context of the calling thread. The context contains
  4876. the content of the registers, the signal mask, and the current
  4877. stack. Executing the contents would start at the point where the
  4878. ‘getcontext’ call just returned.
  4879. The function returns ‘0’ if successful. Otherwise it returns ‘-1’
  4880. and sets ERRNO accordingly.
  4881. The ‘getcontext’ function is similar to ‘setjmp’ but it does not
  4882. provide an indication of whether ‘getcontext’ is returning for the first
  4883. time or whether an initialized context has just been restored. If this
  4884. is necessary the user has to determine this herself. This must be done
  4885. carefully since the context contains registers which might contain
  4886. register variables. This is a good situation to define variables with
  4887. ‘volatile’.
  4888. Once the context variable is initialized it can be used as is or it
  4889. can be modified using the ‘makecontext’ function. The latter is
  4890. normally done when implementing co-routines or similar constructs.
  4891. -- Function: void makecontext (ucontext_t *UCP, void (*FUNC) (void),
  4892. int ARGC, …)
  4893. Preliminary: | MT-Safe race:ucp | AS-Safe | AC-Safe | *Note POSIX
  4894. Safety Concepts::.
  4895. The UCP parameter passed to ‘makecontext’ shall be initialized by a
  4896. call to ‘getcontext’. The context will be modified in a way such
  4897. that if the context is resumed it will start by calling the
  4898. function ‘func’ which gets ARGC integer arguments passed. The
  4899. integer arguments which are to be passed should follow the ARGC
  4900. parameter in the call to ‘makecontext’.
  4901. Before the call to this function the ‘uc_stack’ and ‘uc_link’
  4902. element of the UCP structure should be initialized. The ‘uc_stack’
  4903. element describes the stack which is used for this context. No two
  4904. contexts which are used at the same time should use the same memory
  4905. region for a stack.
  4906. The ‘uc_link’ element of the object pointed to by UCP should be a
  4907. pointer to the context to be executed when the function FUNC
  4908. returns or it should be a null pointer. See ‘setcontext’ for more
  4909. information about the exact use.
  4910. While allocating the memory for the stack one has to be careful.
  4911. Most modern processors keep track of whether a certain memory region is
  4912. allowed to contain code which is executed or not. Data segments and
  4913. heap memory are normally not tagged to allow this. The result is that
  4914. programs would fail. Examples for such code include the calling
  4915. sequences the GNU C compiler generates for calls to nested functions.
  4916. Safe ways to allocate stacks correctly include using memory on the
  4917. original thread’s stack or explicitly allocating memory tagged for
  4918. execution using (*note Memory-mapped I/O::).
  4919. *Compatibility note*: The current Unix standard is very imprecise
  4920. about the way the stack is allocated. All implementations seem to agree
  4921. that the ‘uc_stack’ element must be used but the values stored in the
  4922. elements of the ‘stack_t’ value are unclear. The GNU C Library and most
  4923. other Unix implementations require the ‘ss_sp’ value of the ‘uc_stack’
  4924. element to point to the base of the memory region allocated for the
  4925. stack and the size of the memory region is stored in ‘ss_size’. There
  4926. are implementations out there which require ‘ss_sp’ to be set to the
  4927. value the stack pointer will have (which can, depending on the direction
  4928. the stack grows, be different). This difference makes the ‘makecontext’
  4929. function hard to use and it requires detection of the platform at
  4930. compile time.
  4931. -- Function: int setcontext (const ucontext_t *UCP)
  4932. Preliminary: | MT-Safe race:ucp | AS-Unsafe corrupt | AC-Unsafe
  4933. corrupt | *Note POSIX Safety Concepts::.
  4934. The ‘setcontext’ function restores the context described by UCP.
  4935. The context is not modified and can be reused as often as wanted.
  4936. If the context was created by ‘getcontext’ execution resumes with
  4937. the registers filled with the same values and the same stack as if
  4938. the ‘getcontext’ call just returned.
  4939. If the context was modified with a call to ‘makecontext’ execution
  4940. continues with the function passed to ‘makecontext’ which gets the
  4941. specified parameters passed. If this function returns execution is
  4942. resumed in the context which was referenced by the ‘uc_link’
  4943. element of the context structure passed to ‘makecontext’ at the
  4944. time of the call. If ‘uc_link’ was a null pointer the application
  4945. terminates normally with an exit status value of ‘EXIT_SUCCESS’
  4946. (*note Program Termination::).
  4947. If the context was created by a call to a signal handler or from
  4948. any other source then the behaviour of ‘setcontext’ is unspecified.
  4949. Since the context contains information about the stack no two
  4950. threads should use the same context at the same time. The result
  4951. in most cases would be disastrous.
  4952. The ‘setcontext’ function does not return unless an error occurred
  4953. in which case it returns ‘-1’.
  4954. The ‘setcontext’ function simply replaces the current context with
  4955. the one described by the UCP parameter. This is often useful but there
  4956. are situations where the current context has to be preserved.
  4957. -- Function: int swapcontext (ucontext_t *restrict OUCP, const
  4958. ucontext_t *restrict UCP)
  4959. Preliminary: | MT-Safe race:oucp race:ucp | AS-Unsafe corrupt |
  4960. AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  4961. The ‘swapcontext’ function is similar to ‘setcontext’ but instead
  4962. of just replacing the current context the latter is first saved in
  4963. the object pointed to by OUCP as if this was a call to
  4964. ‘getcontext’. The saved context would resume after the call to
  4965. ‘swapcontext’.
  4966. Once the current context is saved the context described in UCP is
  4967. installed and execution continues as described in this context.
  4968. If ‘swapcontext’ succeeds the function does not return unless the
  4969. context OUCP is used without prior modification by ‘makecontext’.
  4970. The return value in this case is ‘0’. If the function fails it
  4971. returns ‘-1’ and sets ERRNO accordingly.
  4972. Example for SVID Context Handling
  4973. =================================
  4974. The easiest way to use the context handling functions is as a
  4975. replacement for ‘setjmp’ and ‘longjmp’. The context contains on most
  4976. platforms more information which may lead to fewer surprises but this
  4977. also means using these functions is more expensive (besides being less
  4978. portable).
  4979. int
  4980. random_search (int n, int (*fp) (int, ucontext_t *))
  4981. {
  4982. volatile int cnt = 0;
  4983. ucontext_t uc;
  4984. /* Safe current context. */
  4985. if (getcontext (&uc) < 0)
  4986. return -1;
  4987. /* If we have not tried N times try again. */
  4988. if (cnt++ < n)
  4989. /* Call the function with a new random number
  4990. and the context. */
  4991. if (fp (rand (), &uc) != 0)
  4992. /* We found what we were looking for. */
  4993. return 1;
  4994. /* Not found. */
  4995. return 0;
  4996. }
  4997. Using contexts in such a way enables emulating exception handling.
  4998. The search functions passed in the FP parameter could be very large,
  4999. nested, and complex which would make it complicated (or at least would
  5000. require a lot of code) to leave the function with an error value which
  5001. has to be passed down to the caller. By using the context it is
  5002. possible to leave the search function in one step and allow restarting
  5003. the search which also has the nice side effect that it can be
  5004. significantly faster.
  5005. Something which is harder to implement with ‘setjmp’ and ‘longjmp’ is
  5006. to switch temporarily to a different execution path and then resume
  5007. where execution was stopped.
  5008. #include <signal.h>
  5009. #include <stdio.h>
  5010. #include <stdlib.h>
  5011. #include <ucontext.h>
  5012. #include <sys/time.h>
  5013. /* Set by the signal handler. */
  5014. static volatile int expired;
  5015. /* The contexts. */
  5016. static ucontext_t uc[3];
  5017. /* We do only a certain number of switches. */
  5018. static int switches;
  5019. /* This is the function doing the work. It is just a
  5020. skeleton, real code has to be filled in. */
  5021. static void
  5022. f (int n)
  5023. {
  5024. int m = 0;
  5025. while (1)
  5026. {
  5027. /* This is where the work would be done. */
  5028. if (++m % 100 == 0)
  5029. {
  5030. putchar ('.');
  5031. fflush (stdout);
  5032. }
  5033. /* Regularly the EXPIRE variable must be checked. */
  5034. if (expired)
  5035. {
  5036. /* We do not want the program to run forever. */
  5037. if (++switches == 20)
  5038. return;
  5039. printf ("\nswitching from %d to %d\n", n, 3 - n);
  5040. expired = 0;
  5041. /* Switch to the other context, saving the current one. */
  5042. swapcontext (&uc[n], &uc[3 - n]);
  5043. }
  5044. }
  5045. }
  5046. /* This is the signal handler which simply set the variable. */
  5047. void
  5048. handler (int signal)
  5049. {
  5050. expired = 1;
  5051. }
  5052. int
  5053. main (void)
  5054. {
  5055. struct sigaction sa;
  5056. struct itimerval it;
  5057. char st1[8192];
  5058. char st2[8192];
  5059. /* Initialize the data structures for the interval timer. */
  5060. sa.sa_flags = SA_RESTART;
  5061. sigfillset (&sa.sa_mask);
  5062. sa.sa_handler = handler;
  5063. it.it_interval.tv_sec = 0;
  5064. it.it_interval.tv_usec = 1;
  5065. it.it_value = it.it_interval;
  5066. /* Install the timer and get the context we can manipulate. */
  5067. if (sigaction (SIGPROF, &sa, NULL) < 0
  5068. || setitimer (ITIMER_PROF, &it, NULL) < 0
  5069. || getcontext (&uc[1]) == -1
  5070. || getcontext (&uc[2]) == -1)
  5071. abort ();
  5072. /* Create a context with a separate stack which causes the
  5073. function ‘f’ to be call with the parameter ‘1’.
  5074. Note that the ‘uc_link’ points to the main context
  5075. which will cause the program to terminate once the function
  5076. return. */
  5077. uc[1].uc_link = &uc[0];
  5078. uc[1].uc_stack.ss_sp = st1;
  5079. uc[1].uc_stack.ss_size = sizeof st1;
  5080. makecontext (&uc[1], (void (*) (void)) f, 1, 1);
  5081. /* Similarly, but ‘2’ is passed as the parameter to ‘f’. */
  5082. uc[2].uc_link = &uc[0];
  5083. uc[2].uc_stack.ss_sp = st2;
  5084. uc[2].uc_stack.ss_size = sizeof st2;
  5085. makecontext (&uc[2], (void (*) (void)) f, 1, 2);
  5086. /* Start running. */
  5087. swapcontext (&uc[0], &uc[1]);
  5088. putchar ('\n');
  5089. return 0;
  5090. }
  5091. This an example how the context functions can be used to implement
  5092. co-routines or cooperative multi-threading. All that has to be done is
  5093. to call every once in a while ‘swapcontext’ to continue running a
  5094. different context. It is not recommended to do the context switching
  5095. from the signal handler directly since leaving the signal handler via
  5096. ‘setcontext’ if the signal was delivered during code that was not
  5097. asynchronous signal safe could lead to problems. Setting a variable in
  5098. the signal handler and checking it in the body of the functions which
  5099. are executed is a safer approach. Since ‘swapcontext’ is saving the
  5100. current context it is possible to have multiple different scheduling
  5101. points in the code. Execution will always resume where it was left.
  5102. 
  5103. File: libc.info, Node: Signal Handling, Next: Program Basics, Prev: Non-Local Exits, Up: Top
  5104. 24 Signal Handling
  5105. ******************
  5106. A "signal" is a software interrupt delivered to a process. The
  5107. operating system uses signals to report exceptional situations to an
  5108. executing program. Some signals report errors such as references to
  5109. invalid memory addresses; others report asynchronous events, such as
  5110. disconnection of a phone line.
  5111. The GNU C Library defines a variety of signal types, each for a
  5112. particular kind of event. Some kinds of events make it inadvisable or
  5113. impossible for the program to proceed as usual, and the corresponding
  5114. signals normally abort the program. Other kinds of signals that report
  5115. harmless events are ignored by default.
  5116. If you anticipate an event that causes signals, you can define a
  5117. handler function and tell the operating system to run it when that
  5118. particular type of signal arrives.
  5119. Finally, one process can send a signal to another process; this
  5120. allows a parent process to abort a child, or two related processes to
  5121. communicate and synchronize.
  5122. * Menu:
  5123. * Concepts of Signals:: Introduction to the signal facilities.
  5124. * Standard Signals:: Particular kinds of signals with
  5125. standard names and meanings.
  5126. * Signal Actions:: Specifying what happens when a
  5127. particular signal is delivered.
  5128. * Defining Handlers:: How to write a signal handler function.
  5129. * Interrupted Primitives:: Signal handlers affect use of ‘open’,
  5130. ‘read’, ‘write’ and other functions.
  5131. * Generating Signals:: How to send a signal to a process.
  5132. * Blocking Signals:: Making the system hold signals temporarily.
  5133. * Waiting for a Signal:: Suspending your program until a signal
  5134. arrives.
  5135. * Signal Stack:: Using a Separate Signal Stack.
  5136. * BSD Signal Handling:: Additional functions for backward
  5137. compatibility with BSD.
  5138. 
  5139. File: libc.info, Node: Concepts of Signals, Next: Standard Signals, Up: Signal Handling
  5140. 24.1 Basic Concepts of Signals
  5141. ==============================
  5142. This section explains basic concepts of how signals are generated, what
  5143. happens after a signal is delivered, and how programs can handle
  5144. signals.
  5145. * Menu:
  5146. * Kinds of Signals:: Some examples of what can cause a signal.
  5147. * Signal Generation:: Concepts of why and how signals occur.
  5148. * Delivery of Signal:: Concepts of what a signal does to the
  5149. process.
  5150. 
  5151. File: libc.info, Node: Kinds of Signals, Next: Signal Generation, Up: Concepts of Signals
  5152. 24.1.1 Some Kinds of Signals
  5153. ----------------------------
  5154. A signal reports the occurrence of an exceptional event. These are some
  5155. of the events that can cause (or "generate", or "raise") a signal:
  5156. • A program error such as dividing by zero or issuing an address
  5157. outside the valid range.
  5158. • A user request to interrupt or terminate the program. Most
  5159. environments are set up to let a user suspend the program by typing
  5160. ‘C-z’, or terminate it with ‘C-c’. Whatever key sequence is used,
  5161. the operating system sends the proper signal to interrupt the
  5162. process.
  5163. • The termination of a child process.
  5164. • Expiration of a timer or alarm.
  5165. • A call to ‘kill’ or ‘raise’ by the same process.
  5166. • A call to ‘kill’ from another process. Signals are a limited but
  5167. useful form of interprocess communication.
  5168. • An attempt to perform an I/O operation that cannot be done.
  5169. Examples are reading from a pipe that has no writer (*note Pipes
  5170. and FIFOs::), and reading or writing to a terminal in certain
  5171. situations (*note Job Control::).
  5172. Each of these kinds of events (excepting explicit calls to ‘kill’ and
  5173. ‘raise’) generates its own particular kind of signal. The various kinds
  5174. of signals are listed and described in detail in *note Standard
  5175. Signals::.
  5176. 
  5177. File: libc.info, Node: Signal Generation, Next: Delivery of Signal, Prev: Kinds of Signals, Up: Concepts of Signals
  5178. 24.1.2 Concepts of Signal Generation
  5179. ------------------------------------
  5180. In general, the events that generate signals fall into three major
  5181. categories: errors, external events, and explicit requests.
  5182. An error means that a program has done something invalid and cannot
  5183. continue execution. But not all kinds of errors generate signals—in
  5184. fact, most do not. For example, opening a nonexistent file is an error,
  5185. but it does not raise a signal; instead, ‘open’ returns ‘-1’. In
  5186. general, errors that are necessarily associated with certain library
  5187. functions are reported by returning a value that indicates an error.
  5188. The errors which raise signals are those which can happen anywhere in
  5189. the program, not just in library calls. These include division by zero
  5190. and invalid memory addresses.
  5191. An external event generally has to do with I/O or other processes.
  5192. These include the arrival of input, the expiration of a timer, and the
  5193. termination of a child process.
  5194. An explicit request means the use of a library function such as
  5195. ‘kill’ whose purpose is specifically to generate a signal.
  5196. Signals may be generated "synchronously" or "asynchronously". A
  5197. synchronous signal pertains to a specific action in the program, and is
  5198. delivered (unless blocked) during that action. Most errors generate
  5199. signals synchronously, and so do explicit requests by a process to
  5200. generate a signal for that same process. On some machines, certain
  5201. kinds of hardware errors (usually floating-point exceptions) are not
  5202. reported completely synchronously, but may arrive a few instructions
  5203. later.
  5204. Asynchronous signals are generated by events outside the control of
  5205. the process that receives them. These signals arrive at unpredictable
  5206. times during execution. External events generate signals
  5207. asynchronously, and so do explicit requests that apply to some other
  5208. process.
  5209. A given type of signal is either typically synchronous or typically
  5210. asynchronous. For example, signals for errors are typically synchronous
  5211. because errors generate signals synchronously. But any type of signal
  5212. can be generated synchronously or asynchronously with an explicit
  5213. request.
  5214. 
  5215. File: libc.info, Node: Delivery of Signal, Prev: Signal Generation, Up: Concepts of Signals
  5216. 24.1.3 How Signals Are Delivered
  5217. --------------------------------
  5218. When a signal is generated, it becomes "pending". Normally it remains
  5219. pending for just a short period of time and then is "delivered" to the
  5220. process that was signaled. However, if that kind of signal is currently
  5221. "blocked", it may remain pending indefinitely—until signals of that kind
  5222. are "unblocked". Once unblocked, it will be delivered immediately.
  5223. *Note Blocking Signals::.
  5224. When the signal is delivered, whether right away or after a long
  5225. delay, the "specified action" for that signal is taken. For certain
  5226. signals, such as ‘SIGKILL’ and ‘SIGSTOP’, the action is fixed, but for
  5227. most signals, the program has a choice: ignore the signal, specify a
  5228. "handler function", or accept the "default action" for that kind of
  5229. signal. The program specifies its choice using functions such as
  5230. ‘signal’ or ‘sigaction’ (*note Signal Actions::). We sometimes say that
  5231. a handler "catches" the signal. While the handler is running, that
  5232. particular signal is normally blocked.
  5233. If the specified action for a kind of signal is to ignore it, then
  5234. any such signal which is generated is discarded immediately. This
  5235. happens even if the signal is also blocked at the time. A signal
  5236. discarded in this way will never be delivered, not even if the program
  5237. subsequently specifies a different action for that kind of signal and
  5238. then unblocks it.
  5239. If a signal arrives which the program has neither handled nor
  5240. ignored, its "default action" takes place. Each kind of signal has its
  5241. own default action, documented below (*note Standard Signals::). For
  5242. most kinds of signals, the default action is to terminate the process.
  5243. For certain kinds of signals that represent “harmless” events, the
  5244. default action is to do nothing.
  5245. When a signal terminates a process, its parent process can determine
  5246. the cause of termination by examining the termination status code
  5247. reported by the ‘wait’ or ‘waitpid’ functions. (This is discussed in
  5248. more detail in *note Process Completion::.) The information it can get
  5249. includes the fact that termination was due to a signal and the kind of
  5250. signal involved. If a program you run from a shell is terminated by a
  5251. signal, the shell typically prints some kind of error message.
  5252. The signals that normally represent program errors have a special
  5253. property: when one of these signals terminates the process, it also
  5254. writes a "core dump file" which records the state of the process at the
  5255. time of termination. You can examine the core dump with a debugger to
  5256. investigate what caused the error.
  5257. If you raise a “program error” signal by explicit request, and this
  5258. terminates the process, it makes a core dump file just as if the signal
  5259. had been due directly to an error.
  5260. 
  5261. File: libc.info, Node: Standard Signals, Next: Signal Actions, Prev: Concepts of Signals, Up: Signal Handling
  5262. 24.2 Standard Signals
  5263. =====================
  5264. This section lists the names for various standard kinds of signals and
  5265. describes what kind of event they mean. Each signal name is a macro
  5266. which stands for a positive integer—the "signal number" for that kind of
  5267. signal. Your programs should never make assumptions about the numeric
  5268. code for a particular kind of signal, but rather refer to them always by
  5269. the names defined here. This is because the number for a given kind of
  5270. signal can vary from system to system, but the meanings of the names are
  5271. standardized and fairly uniform.
  5272. The signal names are defined in the header file ‘signal.h’.
  5273. -- Macro: int NSIG
  5274. The value of this symbolic constant is the total number of signals
  5275. defined. Since the signal numbers are allocated consecutively,
  5276. ‘NSIG’ is also one greater than the largest defined signal number.
  5277. * Menu:
  5278. * Program Error Signals:: Used to report serious program errors.
  5279. * Termination Signals:: Used to interrupt and/or terminate the
  5280. program.
  5281. * Alarm Signals:: Used to indicate expiration of timers.
  5282. * Asynchronous I/O Signals:: Used to indicate input is available.
  5283. * Job Control Signals:: Signals used to support job control.
  5284. * Operation Error Signals:: Used to report operational system errors.
  5285. * Miscellaneous Signals:: Miscellaneous Signals.
  5286. * Signal Messages:: Printing a message describing a signal.
  5287. 
  5288. File: libc.info, Node: Program Error Signals, Next: Termination Signals, Up: Standard Signals
  5289. 24.2.1 Program Error Signals
  5290. ----------------------------
  5291. The following signals are generated when a serious program error is
  5292. detected by the operating system or the computer itself. In general,
  5293. all of these signals are indications that your program is seriously
  5294. broken in some way, and there’s usually no way to continue the
  5295. computation which encountered the error.
  5296. Some programs handle program error signals in order to tidy up before
  5297. terminating; for example, programs that turn off echoing of terminal
  5298. input should handle program error signals in order to turn echoing back
  5299. on. The handler should end by specifying the default action for the
  5300. signal that happened and then reraising it; this will cause the program
  5301. to terminate with that signal, as if it had not had a handler. (*Note
  5302. Termination in Handler::.)
  5303. Termination is the sensible ultimate outcome from a program error in
  5304. most programs. However, programming systems such as Lisp that can load
  5305. compiled user programs might need to keep executing even if a user
  5306. program incurs an error. These programs have handlers which use
  5307. ‘longjmp’ to return control to the command level.
  5308. The default action for all of these signals is to cause the process
  5309. to terminate. If you block or ignore these signals or establish
  5310. handlers for them that return normally, your program will probably break
  5311. horribly when such signals happen, unless they are generated by ‘raise’
  5312. or ‘kill’ instead of a real error.
  5313. When one of these program error signals terminates a process, it also
  5314. writes a "core dump file" which records the state of the process at the
  5315. time of termination. The core dump file is named ‘core’ and is written
  5316. in whichever directory is current in the process at the time. (On
  5317. GNU/Hurd systems, you can specify the file name for core dumps with the
  5318. environment variable ‘COREFILE’.) The purpose of core dump files is so
  5319. that you can examine them with a debugger to investigate what caused the
  5320. error.
  5321. -- Macro: int SIGFPE
  5322. The ‘SIGFPE’ signal reports a fatal arithmetic error. Although the
  5323. name is derived from “floating-point exception”, this signal
  5324. actually covers all arithmetic errors, including division by zero
  5325. and overflow. If a program stores integer data in a location which
  5326. is then used in a floating-point operation, this often causes an
  5327. “invalid operation” exception, because the processor cannot
  5328. recognize the data as a floating-point number.
  5329. Actual floating-point exceptions are a complicated subject because
  5330. there are many types of exceptions with subtly different meanings,
  5331. and the ‘SIGFPE’ signal doesn’t distinguish between them. The
  5332. ‘IEEE Standard for Binary Floating-Point Arithmetic (ANSI/IEEE Std
  5333. 754-1985 and ANSI/IEEE Std 854-1987)’ defines various
  5334. floating-point exceptions and requires conforming computer systems
  5335. to report their occurrences. However, this standard does not
  5336. specify how the exceptions are reported, or what kinds of handling
  5337. and control the operating system can offer to the programmer.
  5338. BSD systems provide the ‘SIGFPE’ handler with an extra argument that
  5339. distinguishes various causes of the exception. In order to access this
  5340. argument, you must define the handler to accept two arguments, which
  5341. means you must cast it to a one-argument function type in order to
  5342. establish the handler. The GNU C Library does provide this extra
  5343. argument, but the value is meaningful only on operating systems that
  5344. provide the information (BSD systems and GNU systems).
  5345. ‘FPE_INTOVF_TRAP’
  5346. Integer overflow (impossible in a C program unless you enable
  5347. overflow trapping in a hardware-specific fashion).
  5348. ‘FPE_INTDIV_TRAP’
  5349. Integer division by zero.
  5350. ‘FPE_SUBRNG_TRAP’
  5351. Subscript-range (something that C programs never check for).
  5352. ‘FPE_FLTOVF_TRAP’
  5353. Floating overflow trap.
  5354. ‘FPE_FLTDIV_TRAP’
  5355. Floating/decimal division by zero.
  5356. ‘FPE_FLTUND_TRAP’
  5357. Floating underflow trap. (Trapping on floating underflow is not
  5358. normally enabled.)
  5359. ‘FPE_DECOVF_TRAP’
  5360. Decimal overflow trap. (Only a few machines have decimal
  5361. arithmetic and C never uses it.)
  5362. -- Macro: int SIGILL
  5363. The name of this signal is derived from “illegal instruction”; it
  5364. usually means your program is trying to execute garbage or a
  5365. privileged instruction. Since the C compiler generates only valid
  5366. instructions, ‘SIGILL’ typically indicates that the executable file
  5367. is corrupted, or that you are trying to execute data. Some common
  5368. ways of getting into the latter situation are by passing an invalid
  5369. object where a pointer to a function was expected, or by writing
  5370. past the end of an automatic array (or similar problems with
  5371. pointers to automatic variables) and corrupting other data on the
  5372. stack such as the return address of a stack frame.
  5373. ‘SIGILL’ can also be generated when the stack overflows, or when
  5374. the system has trouble running the handler for a signal.
  5375. -- Macro: int SIGSEGV
  5376. This signal is generated when a program tries to read or write
  5377. outside the memory that is allocated for it, or to write memory
  5378. that can only be read. (Actually, the signals only occur when the
  5379. program goes far enough outside to be detected by the system’s
  5380. memory protection mechanism.) The name is an abbreviation for
  5381. “segmentation violation”.
  5382. Common ways of getting a ‘SIGSEGV’ condition include dereferencing
  5383. a null or uninitialized pointer, or when you use a pointer to step
  5384. through an array, but fail to check for the end of the array. It
  5385. varies among systems whether dereferencing a null pointer generates
  5386. ‘SIGSEGV’ or ‘SIGBUS’.
  5387. -- Macro: int SIGBUS
  5388. This signal is generated when an invalid pointer is dereferenced.
  5389. Like ‘SIGSEGV’, this signal is typically the result of
  5390. dereferencing an uninitialized pointer. The difference between the
  5391. two is that ‘SIGSEGV’ indicates an invalid access to valid memory,
  5392. while ‘SIGBUS’ indicates an access to an invalid address. In
  5393. particular, ‘SIGBUS’ signals often result from dereferencing a
  5394. misaligned pointer, such as referring to a four-word integer at an
  5395. address not divisible by four. (Each kind of computer has its own
  5396. requirements for address alignment.)
  5397. The name of this signal is an abbreviation for “bus error”.
  5398. -- Macro: int SIGABRT
  5399. This signal indicates an error detected by the program itself and
  5400. reported by calling ‘abort’. *Note Aborting a Program::.
  5401. -- Macro: int SIGIOT
  5402. Generated by the PDP-11 “iot” instruction. On most machines, this
  5403. is just another name for ‘SIGABRT’.
  5404. -- Macro: int SIGTRAP
  5405. Generated by the machine’s breakpoint instruction, and possibly
  5406. other trap instructions. This signal is used by debuggers. Your
  5407. program will probably only see ‘SIGTRAP’ if it is somehow executing
  5408. bad instructions.
  5409. -- Macro: int SIGEMT
  5410. Emulator trap; this results from certain unimplemented instructions
  5411. which might be emulated in software, or the operating system’s
  5412. failure to properly emulate them.
  5413. -- Macro: int SIGSYS
  5414. Bad system call; that is to say, the instruction to trap to the
  5415. operating system was executed, but the code number for the system
  5416. call to perform was invalid.
  5417. 
  5418. File: libc.info, Node: Termination Signals, Next: Alarm Signals, Prev: Program Error Signals, Up: Standard Signals
  5419. 24.2.2 Termination Signals
  5420. --------------------------
  5421. These signals are all used to tell a process to terminate, in one way or
  5422. another. They have different names because they’re used for slightly
  5423. different purposes, and programs might want to handle them differently.
  5424. The reason for handling these signals is usually so your program can
  5425. tidy up as appropriate before actually terminating. For example, you
  5426. might want to save state information, delete temporary files, or restore
  5427. the previous terminal modes. Such a handler should end by specifying
  5428. the default action for the signal that happened and then reraising it;
  5429. this will cause the program to terminate with that signal, as if it had
  5430. not had a handler. (*Note Termination in Handler::.)
  5431. The (obvious) default action for all of these signals is to cause the
  5432. process to terminate.
  5433. -- Macro: int SIGTERM
  5434. The ‘SIGTERM’ signal is a generic signal used to cause program
  5435. termination. Unlike ‘SIGKILL’, this signal can be blocked,
  5436. handled, and ignored. It is the normal way to politely ask a
  5437. program to terminate.
  5438. The shell command ‘kill’ generates ‘SIGTERM’ by default.
  5439. -- Macro: int SIGINT
  5440. The ‘SIGINT’ (“program interrupt”) signal is sent when the user
  5441. types the INTR character (normally ‘C-c’). *Note Special
  5442. Characters::, for information about terminal driver support for
  5443. ‘C-c’.
  5444. -- Macro: int SIGQUIT
  5445. The ‘SIGQUIT’ signal is similar to ‘SIGINT’, except that it’s
  5446. controlled by a different key—the QUIT character, usually ‘C-\’—and
  5447. produces a core dump when it terminates the process, just like a
  5448. program error signal. You can think of this as a program error
  5449. condition “detected” by the user.
  5450. *Note Program Error Signals::, for information about core dumps.
  5451. *Note Special Characters::, for information about terminal driver
  5452. support.
  5453. Certain kinds of cleanups are best omitted in handling ‘SIGQUIT’.
  5454. For example, if the program creates temporary files, it should
  5455. handle the other termination requests by deleting the temporary
  5456. files. But it is better for ‘SIGQUIT’ not to delete them, so that
  5457. the user can examine them in conjunction with the core dump.
  5458. -- Macro: int SIGKILL
  5459. The ‘SIGKILL’ signal is used to cause immediate program
  5460. termination. It cannot be handled or ignored, and is therefore
  5461. always fatal. It is also not possible to block this signal.
  5462. This signal is usually generated only by explicit request. Since
  5463. it cannot be handled, you should generate it only as a last resort,
  5464. after first trying a less drastic method such as ‘C-c’ or
  5465. ‘SIGTERM’. If a process does not respond to any other termination
  5466. signals, sending it a ‘SIGKILL’ signal will almost always cause it
  5467. to go away.
  5468. In fact, if ‘SIGKILL’ fails to terminate a process, that by itself
  5469. constitutes an operating system bug which you should report.
  5470. The system will generate ‘SIGKILL’ for a process itself under some
  5471. unusual conditions where the program cannot possibly continue to
  5472. run (even to run a signal handler).
  5473. -- Macro: int SIGHUP
  5474. The ‘SIGHUP’ (“hang-up”) signal is used to report that the user’s
  5475. terminal is disconnected, perhaps because a network or telephone
  5476. connection was broken. For more information about this, see *note
  5477. Control Modes::.
  5478. This signal is also used to report the termination of the
  5479. controlling process on a terminal to jobs associated with that
  5480. session; this termination effectively disconnects all processes in
  5481. the session from the controlling terminal. For more information,
  5482. see *note Termination Internals::.
  5483. 
  5484. File: libc.info, Node: Alarm Signals, Next: Asynchronous I/O Signals, Prev: Termination Signals, Up: Standard Signals
  5485. 24.2.3 Alarm Signals
  5486. --------------------
  5487. These signals are used to indicate the expiration of timers. *Note
  5488. Setting an Alarm::, for information about functions that cause these
  5489. signals to be sent.
  5490. The default behavior for these signals is to cause program
  5491. termination. This default is rarely useful, but no other default would
  5492. be useful; most of the ways of using these signals would require handler
  5493. functions in any case.
  5494. -- Macro: int SIGALRM
  5495. This signal typically indicates expiration of a timer that measures
  5496. real or clock time. It is used by the ‘alarm’ function, for
  5497. example.
  5498. -- Macro: int SIGVTALRM
  5499. This signal typically indicates expiration of a timer that measures
  5500. CPU time used by the current process. The name is an abbreviation
  5501. for “virtual time alarm”.
  5502. -- Macro: int SIGPROF
  5503. This signal typically indicates expiration of a timer that measures
  5504. both CPU time used by the current process, and CPU time expended on
  5505. behalf of the process by the system. Such a timer is used to
  5506. implement code profiling facilities, hence the name of this signal.
  5507. 
  5508. File: libc.info, Node: Asynchronous I/O Signals, Next: Job Control Signals, Prev: Alarm Signals, Up: Standard Signals
  5509. 24.2.4 Asynchronous I/O Signals
  5510. -------------------------------
  5511. The signals listed in this section are used in conjunction with
  5512. asynchronous I/O facilities. You have to take explicit action by
  5513. calling ‘fcntl’ to enable a particular file descriptor to generate these
  5514. signals (*note Interrupt Input::). The default action for these signals
  5515. is to ignore them.
  5516. -- Macro: int SIGIO
  5517. This signal is sent when a file descriptor is ready to perform
  5518. input or output.
  5519. On most operating systems, terminals and sockets are the only kinds
  5520. of files that can generate ‘SIGIO’; other kinds, including ordinary
  5521. files, never generate ‘SIGIO’ even if you ask them to.
  5522. On GNU systems ‘SIGIO’ will always be generated properly if you
  5523. successfully set asynchronous mode with ‘fcntl’.
  5524. -- Macro: int SIGURG
  5525. This signal is sent when “urgent” or out-of-band data arrives on a
  5526. socket. *Note Out-of-Band Data::.
  5527. -- Macro: int SIGPOLL
  5528. This is a System V signal name, more or less similar to ‘SIGIO’.
  5529. It is defined only for compatibility.
  5530. 
  5531. File: libc.info, Node: Job Control Signals, Next: Operation Error Signals, Prev: Asynchronous I/O Signals, Up: Standard Signals
  5532. 24.2.5 Job Control Signals
  5533. --------------------------
  5534. These signals are used to support job control. If your system doesn’t
  5535. support job control, then these macros are defined but the signals
  5536. themselves can’t be raised or handled.
  5537. You should generally leave these signals alone unless you really
  5538. understand how job control works. *Note Job Control::.
  5539. -- Macro: int SIGCHLD
  5540. This signal is sent to a parent process whenever one of its child
  5541. processes terminates or stops.
  5542. The default action for this signal is to ignore it. If you
  5543. establish a handler for this signal while there are child processes
  5544. that have terminated but not reported their status via ‘wait’ or
  5545. ‘waitpid’ (*note Process Completion::), whether your new handler
  5546. applies to those processes or not depends on the particular
  5547. operating system.
  5548. -- Macro: int SIGCLD
  5549. This is an obsolete name for ‘SIGCHLD’.
  5550. -- Macro: int SIGCONT
  5551. You can send a ‘SIGCONT’ signal to a process to make it continue.
  5552. This signal is special—it always makes the process continue if it
  5553. is stopped, before the signal is delivered. The default behavior
  5554. is to do nothing else. You cannot block this signal. You can set
  5555. a handler, but ‘SIGCONT’ always makes the process continue
  5556. regardless.
  5557. Most programs have no reason to handle ‘SIGCONT’; they simply
  5558. resume execution without realizing they were ever stopped. You can
  5559. use a handler for ‘SIGCONT’ to make a program do something special
  5560. when it is stopped and continued—for example, to reprint a prompt
  5561. when it is suspended while waiting for input.
  5562. -- Macro: int SIGSTOP
  5563. The ‘SIGSTOP’ signal stops the process. It cannot be handled,
  5564. ignored, or blocked.
  5565. -- Macro: int SIGTSTP
  5566. The ‘SIGTSTP’ signal is an interactive stop signal. Unlike
  5567. ‘SIGSTOP’, this signal can be handled and ignored.
  5568. Your program should handle this signal if you have a special need
  5569. to leave files or system tables in a secure state when a process is
  5570. stopped. For example, programs that turn off echoing should handle
  5571. ‘SIGTSTP’ so they can turn echoing back on before stopping.
  5572. This signal is generated when the user types the SUSP character
  5573. (normally ‘C-z’). For more information about terminal driver
  5574. support, see *note Special Characters::.
  5575. -- Macro: int SIGTTIN
  5576. A process cannot read from the user’s terminal while it is running
  5577. as a background job. When any process in a background job tries to
  5578. read from the terminal, all of the processes in the job are sent a
  5579. ‘SIGTTIN’ signal. The default action for this signal is to stop
  5580. the process. For more information about how this interacts with
  5581. the terminal driver, see *note Access to the Terminal::.
  5582. -- Macro: int SIGTTOU
  5583. This is similar to ‘SIGTTIN’, but is generated when a process in a
  5584. background job attempts to write to the terminal or set its modes.
  5585. Again, the default action is to stop the process. ‘SIGTTOU’ is
  5586. only generated for an attempt to write to the terminal if the
  5587. ‘TOSTOP’ output mode is set; *note Output Modes::.
  5588. While a process is stopped, no more signals can be delivered to it
  5589. until it is continued, except ‘SIGKILL’ signals and (obviously)
  5590. ‘SIGCONT’ signals. The signals are marked as pending, but not delivered
  5591. until the process is continued. The ‘SIGKILL’ signal always causes
  5592. termination of the process and can’t be blocked, handled or ignored.
  5593. You can ignore ‘SIGCONT’, but it always causes the process to be
  5594. continued anyway if it is stopped. Sending a ‘SIGCONT’ signal to a
  5595. process causes any pending stop signals for that process to be
  5596. discarded. Likewise, any pending ‘SIGCONT’ signals for a process are
  5597. discarded when it receives a stop signal.
  5598. When a process in an orphaned process group (*note Orphaned Process
  5599. Groups::) receives a ‘SIGTSTP’, ‘SIGTTIN’, or ‘SIGTTOU’ signal and does
  5600. not handle it, the process does not stop. Stopping the process would
  5601. probably not be very useful, since there is no shell program that will
  5602. notice it stop and allow the user to continue it. What happens instead
  5603. depends on the operating system you are using. Some systems may do
  5604. nothing; others may deliver another signal instead, such as ‘SIGKILL’ or
  5605. ‘SIGHUP’. On GNU/Hurd systems, the process dies with ‘SIGKILL’; this
  5606. avoids the problem of many stopped, orphaned processes lying around the
  5607. system.
  5608. 
  5609. File: libc.info, Node: Operation Error Signals, Next: Miscellaneous Signals, Prev: Job Control Signals, Up: Standard Signals
  5610. 24.2.6 Operation Error Signals
  5611. ------------------------------
  5612. These signals are used to report various errors generated by an
  5613. operation done by the program. They do not necessarily indicate a
  5614. programming error in the program, but an error that prevents an
  5615. operating system call from completing. The default action for all of
  5616. them is to cause the process to terminate.
  5617. -- Macro: int SIGPIPE
  5618. Broken pipe. If you use pipes or FIFOs, you have to design your
  5619. application so that one process opens the pipe for reading before
  5620. another starts writing. If the reading process never starts, or
  5621. terminates unexpectedly, writing to the pipe or FIFO raises a
  5622. ‘SIGPIPE’ signal. If ‘SIGPIPE’ is blocked, handled or ignored, the
  5623. offending call fails with ‘EPIPE’ instead.
  5624. Pipes and FIFO special files are discussed in more detail in *note
  5625. Pipes and FIFOs::.
  5626. Another cause of ‘SIGPIPE’ is when you try to output to a socket
  5627. that isn’t connected. *Note Sending Data::.
  5628. -- Macro: int SIGLOST
  5629. Resource lost. This signal is generated when you have an advisory
  5630. lock on an NFS file, and the NFS server reboots and forgets about
  5631. your lock.
  5632. On GNU/Hurd systems, ‘SIGLOST’ is generated when any server program
  5633. dies unexpectedly. It is usually fine to ignore the signal;
  5634. whatever call was made to the server that died just returns an
  5635. error.
  5636. -- Macro: int SIGXCPU
  5637. CPU time limit exceeded. This signal is generated when the process
  5638. exceeds its soft resource limit on CPU time. *Note Limits on
  5639. Resources::.
  5640. -- Macro: int SIGXFSZ
  5641. File size limit exceeded. This signal is generated when the
  5642. process attempts to extend a file so it exceeds the process’s soft
  5643. resource limit on file size. *Note Limits on Resources::.
  5644. 
  5645. File: libc.info, Node: Miscellaneous Signals, Next: Signal Messages, Prev: Operation Error Signals, Up: Standard Signals
  5646. 24.2.7 Miscellaneous Signals
  5647. ----------------------------
  5648. These signals are used for various other purposes. In general, they
  5649. will not affect your program unless it explicitly uses them for
  5650. something.
  5651. -- Macro: int SIGUSR1
  5652. -- Macro: int SIGUSR2
  5653. The ‘SIGUSR1’ and ‘SIGUSR2’ signals are set aside for you to use
  5654. any way you want. They’re useful for simple interprocess
  5655. communication, if you write a signal handler for them in the
  5656. program that receives the signal.
  5657. There is an example showing the use of ‘SIGUSR1’ and ‘SIGUSR2’ in
  5658. *note Signaling Another Process::.
  5659. The default action is to terminate the process.
  5660. -- Macro: int SIGWINCH
  5661. Window size change. This is generated on some systems (including
  5662. GNU) when the terminal driver’s record of the number of rows and
  5663. columns on the screen is changed. The default action is to ignore
  5664. it.
  5665. If a program does full-screen display, it should handle ‘SIGWINCH’.
  5666. When the signal arrives, it should fetch the new screen size and
  5667. reformat its display accordingly.
  5668. -- Macro: int SIGINFO
  5669. Information request. On 4.4 BSD and GNU/Hurd systems, this signal
  5670. is sent to all the processes in the foreground process group of the
  5671. controlling terminal when the user types the STATUS character in
  5672. canonical mode; *note Signal Characters::.
  5673. If the process is the leader of the process group, the default
  5674. action is to print some status information about the system and
  5675. what the process is doing. Otherwise the default is to do nothing.
  5676. 
  5677. File: libc.info, Node: Signal Messages, Prev: Miscellaneous Signals, Up: Standard Signals
  5678. 24.2.8 Signal Messages
  5679. ----------------------
  5680. We mentioned above that the shell prints a message describing the signal
  5681. that terminated a child process. The clean way to print a message
  5682. describing a signal is to use the functions ‘strsignal’ and ‘psignal’.
  5683. These functions use a signal number to specify which kind of signal to
  5684. describe. The signal number may come from the termination status of a
  5685. child process (*note Process Completion::) or it may come from a signal
  5686. handler in the same process.
  5687. -- Function: char * strsignal (int SIGNUM)
  5688. Preliminary: | MT-Unsafe race:strsignal locale | AS-Unsafe init
  5689. i18n corrupt heap | AC-Unsafe init corrupt mem | *Note POSIX Safety
  5690. Concepts::.
  5691. This function returns a pointer to a statically-allocated string
  5692. containing a message describing the signal SIGNUM. You should not
  5693. modify the contents of this string; and, since it can be rewritten
  5694. on subsequent calls, you should save a copy of it if you need to
  5695. reference it later.
  5696. This function is a GNU extension, declared in the header file
  5697. ‘string.h’.
  5698. -- Function: void psignal (int SIGNUM, const char *MESSAGE)
  5699. Preliminary: | MT-Safe locale | AS-Unsafe corrupt i18n heap |
  5700. AC-Unsafe lock corrupt mem | *Note POSIX Safety Concepts::.
  5701. This function prints a message describing the signal SIGNUM to the
  5702. standard error output stream ‘stderr’; see *note Standard
  5703. Streams::.
  5704. If you call ‘psignal’ with a MESSAGE that is either a null pointer
  5705. or an empty string, ‘psignal’ just prints the message corresponding
  5706. to SIGNUM, adding a trailing newline.
  5707. If you supply a non-null MESSAGE argument, then ‘psignal’ prefixes
  5708. its output with this string. It adds a colon and a space character
  5709. to separate the MESSAGE from the string corresponding to SIGNUM.
  5710. This function is a BSD feature, declared in the header file
  5711. ‘signal.h’.
  5712. There is also an array ‘sys_siglist’ which contains the messages for
  5713. the various signal codes. This array exists on BSD systems, unlike
  5714. ‘strsignal’.
  5715. 
  5716. File: libc.info, Node: Signal Actions, Next: Defining Handlers, Prev: Standard Signals, Up: Signal Handling
  5717. 24.3 Specifying Signal Actions
  5718. ==============================
  5719. The simplest way to change the action for a signal is to use the
  5720. ‘signal’ function. You can specify a built-in action (such as to ignore
  5721. the signal), or you can "establish a handler".
  5722. The GNU C Library also implements the more versatile ‘sigaction’
  5723. facility. This section describes both facilities and gives suggestions
  5724. on which to use when.
  5725. * Menu:
  5726. * Basic Signal Handling:: The simple ‘signal’ function.
  5727. * Advanced Signal Handling:: The more powerful ‘sigaction’ function.
  5728. * Signal and Sigaction:: How those two functions interact.
  5729. * Sigaction Function Example:: An example of using the sigaction function.
  5730. * Flags for Sigaction:: Specifying options for signal handling.
  5731. * Initial Signal Actions:: How programs inherit signal actions.
  5732. 
  5733. File: libc.info, Node: Basic Signal Handling, Next: Advanced Signal Handling, Up: Signal Actions
  5734. 24.3.1 Basic Signal Handling
  5735. ----------------------------
  5736. The ‘signal’ function provides a simple interface for establishing an
  5737. action for a particular signal. The function and associated macros are
  5738. declared in the header file ‘signal.h’.
  5739. -- Data Type: sighandler_t
  5740. This is the type of signal handler functions. Signal handlers take
  5741. one integer argument specifying the signal number, and have return
  5742. type ‘void’. So, you should define handler functions like this:
  5743. void HANDLER (int signum) { … }
  5744. The name ‘sighandler_t’ for this data type is a GNU extension.
  5745. -- Function: sighandler_t signal (int SIGNUM, sighandler_t ACTION)
  5746. Preliminary: | MT-Safe sigintr | AS-Safe | AC-Safe | *Note POSIX
  5747. Safety Concepts::.
  5748. The ‘signal’ function establishes ACTION as the action for the
  5749. signal SIGNUM.
  5750. The first argument, SIGNUM, identifies the signal whose behavior
  5751. you want to control, and should be a signal number. The proper way
  5752. to specify a signal number is with one of the symbolic signal names
  5753. (*note Standard Signals::)—don’t use an explicit number, because
  5754. the numerical code for a given kind of signal may vary from
  5755. operating system to operating system.
  5756. The second argument, ACTION, specifies the action to use for the
  5757. signal SIGNUM. This can be one of the following:
  5758. ‘SIG_DFL’
  5759. ‘SIG_DFL’ specifies the default action for the particular
  5760. signal. The default actions for various kinds of signals are
  5761. stated in *note Standard Signals::.
  5762. ‘SIG_IGN’
  5763. ‘SIG_IGN’ specifies that the signal should be ignored.
  5764. Your program generally should not ignore signals that
  5765. represent serious events or that are normally used to request
  5766. termination. You cannot ignore the ‘SIGKILL’ or ‘SIGSTOP’
  5767. signals at all. You can ignore program error signals like
  5768. ‘SIGSEGV’, but ignoring the error won’t enable the program to
  5769. continue executing meaningfully. Ignoring user requests such
  5770. as ‘SIGINT’, ‘SIGQUIT’, and ‘SIGTSTP’ is unfriendly.
  5771. When you do not wish signals to be delivered during a certain
  5772. part of the program, the thing to do is to block them, not
  5773. ignore them. *Note Blocking Signals::.
  5774. ‘HANDLER’
  5775. Supply the address of a handler function in your program, to
  5776. specify running this handler as the way to deliver the signal.
  5777. For more information about defining signal handler functions,
  5778. see *note Defining Handlers::.
  5779. If you set the action for a signal to ‘SIG_IGN’, or if you set it
  5780. to ‘SIG_DFL’ and the default action is to ignore that signal, then
  5781. any pending signals of that type are discarded (even if they are
  5782. blocked). Discarding the pending signals means that they will
  5783. never be delivered, not even if you subsequently specify another
  5784. action and unblock this kind of signal.
  5785. The ‘signal’ function returns the action that was previously in
  5786. effect for the specified SIGNUM. You can save this value and
  5787. restore it later by calling ‘signal’ again.
  5788. If ‘signal’ can’t honor the request, it returns ‘SIG_ERR’ instead.
  5789. The following ‘errno’ error conditions are defined for this
  5790. function:
  5791. ‘EINVAL’
  5792. You specified an invalid SIGNUM; or you tried to ignore or
  5793. provide a handler for ‘SIGKILL’ or ‘SIGSTOP’.
  5794. *Compatibility Note:* A problem encountered when working with the
  5795. ‘signal’ function is that it has different semantics on BSD and SVID
  5796. systems. The difference is that on SVID systems the signal handler is
  5797. deinstalled after signal delivery. On BSD systems the handler must be
  5798. explicitly deinstalled. In the GNU C Library we use the BSD version by
  5799. default. To use the SVID version you can either use the function
  5800. ‘sysv_signal’ (see below) or use the ‘_XOPEN_SOURCE’ feature select
  5801. macro (*note Feature Test Macros::). In general, use of these functions
  5802. should be avoided because of compatibility problems. It is better to
  5803. use ‘sigaction’ if it is available since the results are much more
  5804. reliable.
  5805. Here is a simple example of setting up a handler to delete temporary
  5806. files when certain fatal signals happen:
  5807. #include <signal.h>
  5808. void
  5809. termination_handler (int signum)
  5810. {
  5811. struct temp_file *p;
  5812. for (p = temp_file_list; p; p = p->next)
  5813. unlink (p->name);
  5814. }
  5815. int
  5816. main (void)
  5817. {
  5818. if (signal (SIGINT, termination_handler) == SIG_IGN)
  5819. signal (SIGINT, SIG_IGN);
  5820. if (signal (SIGHUP, termination_handler) == SIG_IGN)
  5821. signal (SIGHUP, SIG_IGN);
  5822. if (signal (SIGTERM, termination_handler) == SIG_IGN)
  5823. signal (SIGTERM, SIG_IGN);
  5824. }
  5825. Note that if a given signal was previously set to be ignored, this code
  5826. avoids altering that setting. This is because non-job-control shells
  5827. often ignore certain signals when starting children, and it is important
  5828. for the children to respect this.
  5829. We do not handle ‘SIGQUIT’ or the program error signals in this
  5830. example because these are designed to provide information for debugging
  5831. (a core dump), and the temporary files may give useful information.
  5832. -- Function: sighandler_t sysv_signal (int SIGNUM, sighandler_t ACTION)
  5833. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5834. Concepts::.
  5835. The ‘sysv_signal’ implements the behavior of the standard ‘signal’
  5836. function as found on SVID systems. The difference to BSD systems
  5837. is that the handler is deinstalled after a delivery of a signal.
  5838. *Compatibility Note:* As said above for ‘signal’, this function
  5839. should be avoided when possible. ‘sigaction’ is the preferred
  5840. method.
  5841. -- Function: sighandler_t ssignal (int SIGNUM, sighandler_t ACTION)
  5842. Preliminary: | MT-Safe sigintr | AS-Safe | AC-Safe | *Note POSIX
  5843. Safety Concepts::.
  5844. The ‘ssignal’ function does the same thing as ‘signal’; it is
  5845. provided only for compatibility with SVID.
  5846. -- Macro: sighandler_t SIG_ERR
  5847. The value of this macro is used as the return value from ‘signal’
  5848. to indicate an error.
  5849. 
  5850. File: libc.info, Node: Advanced Signal Handling, Next: Signal and Sigaction, Prev: Basic Signal Handling, Up: Signal Actions
  5851. 24.3.2 Advanced Signal Handling
  5852. -------------------------------
  5853. The ‘sigaction’ function has the same basic effect as ‘signal’: to
  5854. specify how a signal should be handled by the process. However,
  5855. ‘sigaction’ offers more control, at the expense of more complexity. In
  5856. particular, ‘sigaction’ allows you to specify additional flags to
  5857. control when the signal is generated and how the handler is invoked.
  5858. The ‘sigaction’ function is declared in ‘signal.h’.
  5859. -- Data Type: struct sigaction
  5860. Structures of type ‘struct sigaction’ are used in the ‘sigaction’
  5861. function to specify all the information about how to handle a
  5862. particular signal. This structure contains at least the following
  5863. members:
  5864. ‘sighandler_t sa_handler’
  5865. This is used in the same way as the ACTION argument to the
  5866. ‘signal’ function. The value can be ‘SIG_DFL’, ‘SIG_IGN’, or
  5867. a function pointer. *Note Basic Signal Handling::.
  5868. ‘sigset_t sa_mask’
  5869. This specifies a set of signals to be blocked while the
  5870. handler runs. Blocking is explained in *note Blocking for
  5871. Handler::. Note that the signal that was delivered is
  5872. automatically blocked by default before its handler is
  5873. started; this is true regardless of the value in ‘sa_mask’.
  5874. If you want that signal not to be blocked within its handler,
  5875. you must write code in the handler to unblock it.
  5876. ‘int sa_flags’
  5877. This specifies various flags which can affect the behavior of
  5878. the signal. These are described in more detail in *note Flags
  5879. for Sigaction::.
  5880. -- Function: int sigaction (int SIGNUM, const struct sigaction
  5881. *restrict ACTION, struct sigaction *restrict OLD-ACTION)
  5882. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5883. Concepts::.
  5884. The ACTION argument is used to set up a new action for the signal
  5885. SIGNUM, while the OLD-ACTION argument is used to return information
  5886. about the action previously associated with this signal. (In other
  5887. words, OLD-ACTION has the same purpose as the ‘signal’ function’s
  5888. return value—you can check to see what the old action in effect for
  5889. the signal was, and restore it later if you want.)
  5890. Either ACTION or OLD-ACTION can be a null pointer. If OLD-ACTION
  5891. is a null pointer, this simply suppresses the return of information
  5892. about the old action. If ACTION is a null pointer, the action
  5893. associated with the signal SIGNUM is unchanged; this allows you to
  5894. inquire about how a signal is being handled without changing that
  5895. handling.
  5896. The return value from ‘sigaction’ is zero if it succeeds, and ‘-1’
  5897. on failure. The following ‘errno’ error conditions are defined for
  5898. this function:
  5899. ‘EINVAL’
  5900. The SIGNUM argument is not valid, or you are trying to trap or
  5901. ignore ‘SIGKILL’ or ‘SIGSTOP’.
  5902. 
  5903. File: libc.info, Node: Signal and Sigaction, Next: Sigaction Function Example, Prev: Advanced Signal Handling, Up: Signal Actions
  5904. 24.3.3 Interaction of ‘signal’ and ‘sigaction’
  5905. ----------------------------------------------
  5906. It’s possible to use both the ‘signal’ and ‘sigaction’ functions within
  5907. a single program, but you have to be careful because they can interact
  5908. in slightly strange ways.
  5909. The ‘sigaction’ function specifies more information than the ‘signal’
  5910. function, so the return value from ‘signal’ cannot express the full
  5911. range of ‘sigaction’ possibilities. Therefore, if you use ‘signal’ to
  5912. save and later reestablish an action, it may not be able to reestablish
  5913. properly a handler that was established with ‘sigaction’.
  5914. To avoid having problems as a result, always use ‘sigaction’ to save
  5915. and restore a handler if your program uses ‘sigaction’ at all. Since
  5916. ‘sigaction’ is more general, it can properly save and reestablish any
  5917. action, regardless of whether it was established originally with
  5918. ‘signal’ or ‘sigaction’.
  5919. On some systems if you establish an action with ‘signal’ and then
  5920. examine it with ‘sigaction’, the handler address that you get may not be
  5921. the same as what you specified with ‘signal’. It may not even be
  5922. suitable for use as an action argument with ‘signal’. But you can rely
  5923. on using it as an argument to ‘sigaction’. This problem never happens
  5924. on GNU systems.
  5925. So, you’re better off using one or the other of the mechanisms
  5926. consistently within a single program.
  5927. *Portability Note:* The basic ‘signal’ function is a feature of
  5928. ISO C, while ‘sigaction’ is part of the POSIX.1 standard. If you are
  5929. concerned about portability to non-POSIX systems, then you should use
  5930. the ‘signal’ function instead.
  5931. 
  5932. File: libc.info, Node: Sigaction Function Example, Next: Flags for Sigaction, Prev: Signal and Sigaction, Up: Signal Actions
  5933. 24.3.4 ‘sigaction’ Function Example
  5934. -----------------------------------
  5935. In *note Basic Signal Handling::, we gave an example of establishing a
  5936. simple handler for termination signals using ‘signal’. Here is an
  5937. equivalent example using ‘sigaction’:
  5938. #include <signal.h>
  5939. void
  5940. termination_handler (int signum)
  5941. {
  5942. struct temp_file *p;
  5943. for (p = temp_file_list; p; p = p->next)
  5944. unlink (p->name);
  5945. }
  5946. int
  5947. main (void)
  5948. {
  5949. struct sigaction new_action, old_action;
  5950. /* Set up the structure to specify the new action. */
  5951. new_action.sa_handler = termination_handler;
  5952. sigemptyset (&new_action.sa_mask);
  5953. new_action.sa_flags = 0;
  5954. sigaction (SIGINT, NULL, &old_action);
  5955. if (old_action.sa_handler != SIG_IGN)
  5956. sigaction (SIGINT, &new_action, NULL);
  5957. sigaction (SIGHUP, NULL, &old_action);
  5958. if (old_action.sa_handler != SIG_IGN)
  5959. sigaction (SIGHUP, &new_action, NULL);
  5960. sigaction (SIGTERM, NULL, &old_action);
  5961. if (old_action.sa_handler != SIG_IGN)
  5962. sigaction (SIGTERM, &new_action, NULL);
  5963. }
  5964. The program just loads the ‘new_action’ structure with the desired
  5965. parameters and passes it in the ‘sigaction’ call. The usage of
  5966. ‘sigemptyset’ is described later; see *note Blocking Signals::.
  5967. As in the example using ‘signal’, we avoid handling signals
  5968. previously set to be ignored. Here we can avoid altering the signal
  5969. handler even momentarily, by using the feature of ‘sigaction’ that lets
  5970. us examine the current action without specifying a new one.
  5971. Here is another example. It retrieves information about the current
  5972. action for ‘SIGINT’ without changing that action.
  5973. struct sigaction query_action;
  5974. if (sigaction (SIGINT, NULL, &query_action) < 0)
  5975. /* ‘sigaction’ returns -1 in case of error. */
  5976. else if (query_action.sa_handler == SIG_DFL)
  5977. /* ‘SIGINT’ is handled in the default, fatal manner. */
  5978. else if (query_action.sa_handler == SIG_IGN)
  5979. /* ‘SIGINT’ is ignored. */
  5980. else
  5981. /* A programmer-defined signal handler is in effect. */