libc.info-10 291 KB

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