libc.info-11 297 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655
  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: Handler Returns, Next: Termination in Handler, Up: Defining Handlers
  2099. 24.4.1 Signal Handlers that Return
  2100. ----------------------------------
  2101. Handlers which return normally are usually used for signals such as
  2102. ‘SIGALRM’ and the I/O and interprocess communication signals. But a
  2103. handler for ‘SIGINT’ might also return normally after setting a flag
  2104. that tells the program to exit at a convenient time.
  2105. It is not safe to return normally from the handler for a program
  2106. error signal, because the behavior of the program when the handler
  2107. function returns is not defined after a program error. *Note Program
  2108. Error Signals::.
  2109. Handlers that return normally must modify some global variable in
  2110. order to have any effect. Typically, the variable is one that is
  2111. examined periodically by the program during normal operation. Its data
  2112. type should be ‘sig_atomic_t’ for reasons described in *note Atomic Data
  2113. Access::.
  2114. Here is a simple example of such a program. It executes the body of
  2115. the loop until it has noticed that a ‘SIGALRM’ signal has arrived. This
  2116. technique is useful because it allows the iteration in progress when the
  2117. signal arrives to complete before the loop exits.
  2118. #include <signal.h>
  2119. #include <stdio.h>
  2120. #include <stdlib.h>
  2121. /* This flag controls termination of the main loop. */
  2122. volatile sig_atomic_t keep_going = 1;
  2123. /* The signal handler just clears the flag and re-enables itself. */
  2124. void
  2125. catch_alarm (int sig)
  2126. {
  2127. keep_going = 0;
  2128. signal (sig, catch_alarm);
  2129. }
  2130. void
  2131. do_stuff (void)
  2132. {
  2133. puts ("Doing stuff while waiting for alarm....");
  2134. }
  2135. int
  2136. main (void)
  2137. {
  2138. /* Establish a handler for SIGALRM signals. */
  2139. signal (SIGALRM, catch_alarm);
  2140. /* Set an alarm to go off in a little while. */
  2141. alarm (2);
  2142. /* Check the flag once in a while to see when to quit. */
  2143. while (keep_going)
  2144. do_stuff ();
  2145. return EXIT_SUCCESS;
  2146. }
  2147. 
  2148. File: libc.info, Node: Termination in Handler, Next: Longjmp in Handler, Prev: Handler Returns, Up: Defining Handlers
  2149. 24.4.2 Handlers That Terminate the Process
  2150. ------------------------------------------
  2151. Handler functions that terminate the program are typically used to cause
  2152. orderly cleanup or recovery from program error signals and interactive
  2153. interrupts.
  2154. The cleanest way for a handler to terminate the process is to raise
  2155. the same signal that ran the handler in the first place. Here is how to
  2156. do this:
  2157. volatile sig_atomic_t fatal_error_in_progress = 0;
  2158. void
  2159. fatal_error_signal (int sig)
  2160. {
  2161. /* Since this handler is established for more than one kind of signal,
  2162. it might still get invoked recursively by delivery of some other kind
  2163. of signal. Use a static variable to keep track of that. */
  2164. if (fatal_error_in_progress)
  2165. raise (sig);
  2166. fatal_error_in_progress = 1;
  2167. /* Now do the clean up actions:
  2168. - reset terminal modes
  2169. - kill child processes
  2170. - remove lock files */
  2171. ...
  2172. /* Now reraise the signal. We reactivate the signal’s
  2173. default handling, which is to terminate the process.
  2174. We could just call ‘exit’ or ‘abort’,
  2175. but reraising the signal sets the return status
  2176. from the process correctly. */
  2177. signal (sig, SIG_DFL);
  2178. raise (sig);
  2179. }
  2180. 
  2181. File: libc.info, Node: Longjmp in Handler, Next: Signals in Handler, Prev: Termination in Handler, Up: Defining Handlers
  2182. 24.4.3 Nonlocal Control Transfer in Handlers
  2183. --------------------------------------------
  2184. You can do a nonlocal transfer of control out of a signal handler using
  2185. the ‘setjmp’ and ‘longjmp’ facilities (*note Non-Local Exits::).
  2186. When the handler does a nonlocal control transfer, the part of the
  2187. program that was running will not continue. If this part of the program
  2188. was in the middle of updating an important data structure, the data
  2189. structure will remain inconsistent. Since the program does not
  2190. terminate, the inconsistency is likely to be noticed later on.
  2191. There are two ways to avoid this problem. One is to block the signal
  2192. for the parts of the program that update important data structures.
  2193. Blocking the signal delays its delivery until it is unblocked, once the
  2194. critical updating is finished. *Note Blocking Signals::.
  2195. The other way is to re-initialize the crucial data structures in the
  2196. signal handler, or to make their values consistent.
  2197. Here is a rather schematic example showing the reinitialization of
  2198. one global variable.
  2199. #include <signal.h>
  2200. #include <setjmp.h>
  2201. jmp_buf return_to_top_level;
  2202. volatile sig_atomic_t waiting_for_input;
  2203. void
  2204. handle_sigint (int signum)
  2205. {
  2206. /* We may have been waiting for input when the signal arrived,
  2207. but we are no longer waiting once we transfer control. */
  2208. waiting_for_input = 0;
  2209. longjmp (return_to_top_level, 1);
  2210. }
  2211. int
  2212. main (void)
  2213. {
  2214. ...
  2215. signal (SIGINT, sigint_handler);
  2216. ...
  2217. while (1) {
  2218. prepare_for_command ();
  2219. if (setjmp (return_to_top_level) == 0)
  2220. read_and_execute_command ();
  2221. }
  2222. }
  2223. /* Imagine this is a subroutine used by various commands. */
  2224. char *
  2225. read_data ()
  2226. {
  2227. if (input_from_terminal) {
  2228. waiting_for_input = 1;
  2229. ...
  2230. waiting_for_input = 0;
  2231. } else {
  2232. ...
  2233. }
  2234. }
  2235. 
  2236. File: libc.info, Node: Signals in Handler, Next: Merged Signals, Prev: Longjmp in Handler, Up: Defining Handlers
  2237. 24.4.4 Signals Arriving While a Handler Runs
  2238. --------------------------------------------
  2239. What happens if another signal arrives while your signal handler
  2240. function is running?
  2241. When the handler for a particular signal is invoked, that signal is
  2242. automatically blocked until the handler returns. That means that if two
  2243. signals of the same kind arrive close together, the second one will be
  2244. held until the first has been handled. (The handler can explicitly
  2245. unblock the signal using ‘sigprocmask’, if you want to allow more
  2246. signals of this type to arrive; see *note Process Signal Mask::.)
  2247. However, your handler can still be interrupted by delivery of another
  2248. kind of signal. To avoid this, you can use the ‘sa_mask’ member of the
  2249. action structure passed to ‘sigaction’ to explicitly specify which
  2250. signals should be blocked while the signal handler runs. These signals
  2251. are in addition to the signal for which the handler was invoked, and any
  2252. other signals that are normally blocked by the process. *Note Blocking
  2253. for Handler::.
  2254. When the handler returns, the set of blocked signals is restored to
  2255. the value it had before the handler ran. So using ‘sigprocmask’ inside
  2256. the handler only affects what signals can arrive during the execution of
  2257. the handler itself, not what signals can arrive once the handler
  2258. returns.
  2259. *Portability Note:* Always use ‘sigaction’ to establish a handler for
  2260. a signal that you expect to receive asynchronously, if you want your
  2261. program to work properly on System V Unix. On this system, the handling
  2262. of a signal whose handler was established with ‘signal’ automatically
  2263. sets the signal’s action back to ‘SIG_DFL’, and the handler must
  2264. re-establish itself each time it runs. This practice, while
  2265. inconvenient, does work when signals cannot arrive in succession.
  2266. However, if another signal can arrive right away, it may arrive before
  2267. the handler can re-establish itself. Then the second signal would
  2268. receive the default handling, which could terminate the process.
  2269. 
  2270. File: libc.info, Node: Merged Signals, Next: Nonreentrancy, Prev: Signals in Handler, Up: Defining Handlers
  2271. 24.4.5 Signals Close Together Merge into One
  2272. --------------------------------------------
  2273. If multiple signals of the same type are delivered to your process
  2274. before your signal handler has a chance to be invoked at all, the
  2275. handler may only be invoked once, as if only a single signal had
  2276. arrived. In effect, the signals merge into one. This situation can
  2277. arise when the signal is blocked, or in a multiprocessing environment
  2278. where the system is busy running some other processes while the signals
  2279. are delivered. This means, for example, that you cannot reliably use a
  2280. signal handler to count signals. The only distinction you can reliably
  2281. make is whether at least one signal has arrived since a given time in
  2282. the past.
  2283. Here is an example of a handler for ‘SIGCHLD’ that compensates for
  2284. the fact that the number of signals received may not equal the number of
  2285. child processes that generate them. It assumes that the program keeps
  2286. track of all the child processes with a chain of structures as follows:
  2287. struct process
  2288. {
  2289. struct process *next;
  2290. /* The process ID of this child. */
  2291. int pid;
  2292. /* The descriptor of the pipe or pseudo terminal
  2293. on which output comes from this child. */
  2294. int input_descriptor;
  2295. /* Nonzero if this process has stopped or terminated. */
  2296. sig_atomic_t have_status;
  2297. /* The status of this child; 0 if running,
  2298. otherwise a status value from ‘waitpid’. */
  2299. int status;
  2300. };
  2301. struct process *process_list;
  2302. This example also uses a flag to indicate whether signals have
  2303. arrived since some time in the past—whenever the program last cleared it
  2304. to zero.
  2305. /* Nonzero means some child’s status has changed
  2306. so look at ‘process_list’ for the details. */
  2307. int process_status_change;
  2308. Here is the handler itself:
  2309. void
  2310. sigchld_handler (int signo)
  2311. {
  2312. int old_errno = errno;
  2313. while (1) {
  2314. register int pid;
  2315. int w;
  2316. struct process *p;
  2317. /* Keep asking for a status until we get a definitive result. */
  2318. do
  2319. {
  2320. errno = 0;
  2321. pid = waitpid (WAIT_ANY, &w, WNOHANG | WUNTRACED);
  2322. }
  2323. while (pid <= 0 && errno == EINTR);
  2324. if (pid <= 0) {
  2325. /* A real failure means there are no more
  2326. stopped or terminated child processes, so return. */
  2327. errno = old_errno;
  2328. return;
  2329. }
  2330. /* Find the process that signaled us, and record its status. */
  2331. for (p = process_list; p; p = p->next)
  2332. if (p->pid == pid) {
  2333. p->status = w;
  2334. /* Indicate that the ‘status’ field
  2335. has data to look at. We do this only after storing it. */
  2336. p->have_status = 1;
  2337. /* If process has terminated, stop waiting for its output. */
  2338. if (WIFSIGNALED (w) || WIFEXITED (w))
  2339. if (p->input_descriptor)
  2340. FD_CLR (p->input_descriptor, &input_wait_mask);
  2341. /* The program should check this flag from time to time
  2342. to see if there is any news in ‘process_list’. */
  2343. ++process_status_change;
  2344. }
  2345. /* Loop around to handle all the processes
  2346. that have something to tell us. */
  2347. }
  2348. }
  2349. Here is the proper way to check the flag ‘process_status_change’:
  2350. if (process_status_change) {
  2351. struct process *p;
  2352. process_status_change = 0;
  2353. for (p = process_list; p; p = p->next)
  2354. if (p->have_status) {
  2355. ... Examine ‘p->status’ ...
  2356. }
  2357. }
  2358. It is vital to clear the flag before examining the list; otherwise, if a
  2359. signal were delivered just before the clearing of the flag, and after
  2360. the appropriate element of the process list had been checked, the status
  2361. change would go unnoticed until the next signal arrived to set the flag
  2362. again. You could, of course, avoid this problem by blocking the signal
  2363. while scanning the list, but it is much more elegant to guarantee
  2364. correctness by doing things in the right order.
  2365. The loop which checks process status avoids examining ‘p->status’
  2366. until it sees that status has been validly stored. This is to make sure
  2367. that the status cannot change in the middle of accessing it. Once
  2368. ‘p->have_status’ is set, it means that the child process is stopped or
  2369. terminated, and in either case, it cannot stop or terminate again until
  2370. the program has taken notice. *Note Atomic Usage::, for more
  2371. information about coping with interruptions during accesses of a
  2372. variable.
  2373. Here is another way you can test whether the handler has run since
  2374. the last time you checked. This technique uses a counter which is never
  2375. changed outside the handler. Instead of clearing the count, the program
  2376. remembers the previous value and sees whether it has changed since the
  2377. previous check. The advantage of this method is that different parts of
  2378. the program can check independently, each part checking whether there
  2379. has been a signal since that part last checked.
  2380. sig_atomic_t process_status_change;
  2381. sig_atomic_t last_process_status_change;
  2382. ...
  2383. {
  2384. sig_atomic_t prev = last_process_status_change;
  2385. last_process_status_change = process_status_change;
  2386. if (last_process_status_change != prev) {
  2387. struct process *p;
  2388. for (p = process_list; p; p = p->next)
  2389. if (p->have_status) {
  2390. ... Examine ‘p->status’ ...
  2391. }
  2392. }
  2393. }
  2394. 
  2395. File: libc.info, Node: Nonreentrancy, Next: Atomic Data Access, Prev: Merged Signals, Up: Defining Handlers
  2396. 24.4.6 Signal Handling and Nonreentrant Functions
  2397. -------------------------------------------------
  2398. Handler functions usually don’t do very much. The best practice is to
  2399. write a handler that does nothing but set an external variable that the
  2400. program checks regularly, and leave all serious work to the program.
  2401. This is best because the handler can be called asynchronously, at
  2402. unpredictable times—perhaps in the middle of a primitive function, or
  2403. even between the beginning and the end of a C operator that requires
  2404. multiple instructions. The data structures being manipulated might
  2405. therefore be in an inconsistent state when the handler function is
  2406. invoked. Even copying one ‘int’ variable into another can take two
  2407. instructions on most machines.
  2408. This means you have to be very careful about what you do in a signal
  2409. handler.
  2410. • If your handler needs to access any global variables from your
  2411. program, declare those variables ‘volatile’. This tells the
  2412. compiler that the value of the variable might change
  2413. asynchronously, and inhibits certain optimizations that would be
  2414. invalidated by such modifications.
  2415. • If you call a function in the handler, make sure it is “reentrant”
  2416. with respect to signals, or else make sure that the signal cannot
  2417. interrupt a call to a related function.
  2418. A function can be non-reentrant if it uses memory that is not on the
  2419. stack.
  2420. • If a function uses a static variable or a global variable, or a
  2421. dynamically-allocated object that it finds for itself, then it is
  2422. non-reentrant and any two calls to the function can interfere.
  2423. For example, suppose that the signal handler uses ‘gethostbyname’.
  2424. This function returns its value in a static object, reusing the
  2425. same object each time. If the signal happens to arrive during a
  2426. call to ‘gethostbyname’, or even after one (while the program is
  2427. still using the value), it will clobber the value that the program
  2428. asked for.
  2429. However, if the program does not use ‘gethostbyname’ or any other
  2430. function that returns information in the same object, or if it
  2431. always blocks signals around each use, then you are safe.
  2432. There are a large number of library functions that return values in
  2433. a fixed object, always reusing the same object in this fashion, and
  2434. all of them cause the same problem. Function descriptions in this
  2435. manual always mention this behavior.
  2436. • If a function uses and modifies an object that you supply, then it
  2437. is potentially non-reentrant; two calls can interfere if they use
  2438. the same object.
  2439. This case arises when you do I/O using streams. Suppose that the
  2440. signal handler prints a message with ‘fprintf’. Suppose that the
  2441. program was in the middle of an ‘fprintf’ call using the same
  2442. stream when the signal was delivered. Both the signal handler’s
  2443. message and the program’s data could be corrupted, because both
  2444. calls operate on the same data structure—the stream itself.
  2445. However, if you know that the stream that the handler uses cannot
  2446. possibly be used by the program at a time when signals can arrive,
  2447. then you are safe. It is no problem if the program uses some other
  2448. stream.
  2449. • On most systems, ‘malloc’ and ‘free’ are not reentrant, because
  2450. they use a static data structure which records what memory blocks
  2451. are free. As a result, no library functions that allocate or free
  2452. memory are reentrant. This includes functions that allocate space
  2453. to store a result.
  2454. The best way to avoid the need to allocate memory in a handler is
  2455. to allocate in advance space for signal handlers to use.
  2456. The best way to avoid freeing memory in a handler is to flag or
  2457. record the objects to be freed, and have the program check from
  2458. time to time whether anything is waiting to be freed. But this
  2459. must be done with care, because placing an object on a chain is not
  2460. atomic, and if it is interrupted by another signal handler that
  2461. does the same thing, you could “lose” one of the objects.
  2462. • Any function that modifies ‘errno’ is non-reentrant, but you can
  2463. correct for this: in the handler, save the original value of
  2464. ‘errno’ and restore it before returning normally. This prevents
  2465. errors that occur within the signal handler from being confused
  2466. with errors from system calls at the point the program is
  2467. interrupted to run the handler.
  2468. This technique is generally applicable; if you want to call in a
  2469. handler a function that modifies a particular object in memory, you
  2470. can make this safe by saving and restoring that object.
  2471. • Merely reading from a memory object is safe provided that you can
  2472. deal with any of the values that might appear in the object at a
  2473. time when the signal can be delivered. Keep in mind that
  2474. assignment to some data types requires more than one instruction,
  2475. which means that the handler could run “in the middle of” an
  2476. assignment to the variable if its type is not atomic. *Note Atomic
  2477. Data Access::.
  2478. • Merely writing into a memory object is safe as long as a sudden
  2479. change in the value, at any time when the handler might run, will
  2480. not disturb anything.
  2481. 
  2482. File: libc.info, Node: Atomic Data Access, Prev: Nonreentrancy, Up: Defining Handlers
  2483. 24.4.7 Atomic Data Access and Signal Handling
  2484. ---------------------------------------------
  2485. Whether the data in your application concerns atoms, or mere text, you
  2486. have to be careful about the fact that access to a single datum is not
  2487. necessarily “atomic”. This means that it can take more than one
  2488. instruction to read or write a single object. In such cases, a signal
  2489. handler might be invoked in the middle of reading or writing the object.
  2490. There are three ways you can cope with this problem. You can use
  2491. data types that are always accessed atomically; you can carefully
  2492. arrange that nothing untoward happens if an access is interrupted, or
  2493. you can block all signals around any access that had better not be
  2494. interrupted (*note Blocking Signals::).
  2495. * Menu:
  2496. * Non-atomic Example:: A program illustrating interrupted access.
  2497. * Types: Atomic Types. Data types that guarantee no interruption.
  2498. * Usage: Atomic Usage. Proving that interruption is harmless.
  2499. 
  2500. File: libc.info, Node: Non-atomic Example, Next: Atomic Types, Up: Atomic Data Access
  2501. 24.4.7.1 Problems with Non-Atomic Access
  2502. ........................................
  2503. Here is an example which shows what can happen if a signal handler runs
  2504. in the middle of modifying a variable. (Interrupting the reading of a
  2505. variable can also lead to paradoxical results, but here we only show
  2506. writing.)
  2507. #include <signal.h>
  2508. #include <stdio.h>
  2509. volatile struct two_words { int a, b; } memory;
  2510. void
  2511. handler(int signum)
  2512. {
  2513. printf ("%d,%d\n", memory.a, memory.b);
  2514. alarm (1);
  2515. }
  2516. int
  2517. main (void)
  2518. {
  2519. static struct two_words zeros = { 0, 0 }, ones = { 1, 1 };
  2520. signal (SIGALRM, handler);
  2521. memory = zeros;
  2522. alarm (1);
  2523. while (1)
  2524. {
  2525. memory = zeros;
  2526. memory = ones;
  2527. }
  2528. }
  2529. This program fills ‘memory’ with zeros, ones, zeros, ones,
  2530. alternating forever; meanwhile, once per second, the alarm signal
  2531. handler prints the current contents. (Calling ‘printf’ in the handler
  2532. is safe in this program because it is certainly not being called outside
  2533. the handler when the signal happens.)
  2534. Clearly, this program can print a pair of zeros or a pair of ones.
  2535. But that’s not all it can do! On most machines, it takes several
  2536. instructions to store a new value in ‘memory’, and the value is stored
  2537. one word at a time. If the signal is delivered in between these
  2538. instructions, the handler might find that ‘memory.a’ is zero and
  2539. ‘memory.b’ is one (or vice versa).
  2540. On some machines it may be possible to store a new value in ‘memory’
  2541. with just one instruction that cannot be interrupted. On these
  2542. machines, the handler will always print two zeros or two ones.
  2543. 
  2544. File: libc.info, Node: Atomic Types, Next: Atomic Usage, Prev: Non-atomic Example, Up: Atomic Data Access
  2545. 24.4.7.2 Atomic Types
  2546. .....................
  2547. To avoid uncertainty about interrupting access to a variable, you can
  2548. use a particular data type for which access is always atomic:
  2549. ‘sig_atomic_t’. Reading and writing this data type is guaranteed to
  2550. happen in a single instruction, so there’s no way for a handler to run
  2551. “in the middle” of an access.
  2552. The type ‘sig_atomic_t’ is always an integer data type, but which one
  2553. it is, and how many bits it contains, may vary from machine to machine.
  2554. -- Data Type: sig_atomic_t
  2555. This is an integer data type. Objects of this type are always
  2556. accessed atomically.
  2557. In practice, you can assume that ‘int’ is atomic. You can also
  2558. assume that pointer types are atomic; that is very convenient. Both of
  2559. these assumptions are true on all of the machines that the GNU C Library
  2560. supports and on all POSIX systems we know of.
  2561. 
  2562. File: libc.info, Node: Atomic Usage, Prev: Atomic Types, Up: Atomic Data Access
  2563. 24.4.7.3 Atomic Usage Patterns
  2564. ..............................
  2565. Certain patterns of access avoid any problem even if an access is
  2566. interrupted. For example, a flag which is set by the handler, and
  2567. tested and cleared by the main program from time to time, is always safe
  2568. even if access actually requires two instructions. To show that this is
  2569. so, we must consider each access that could be interrupted, and show
  2570. that there is no problem if it is interrupted.
  2571. An interrupt in the middle of testing the flag is safe because either
  2572. it’s recognized to be nonzero, in which case the precise value doesn’t
  2573. matter, or it will be seen to be nonzero the next time it’s tested.
  2574. An interrupt in the middle of clearing the flag is no problem because
  2575. either the value ends up zero, which is what happens if a signal comes
  2576. in just before the flag is cleared, or the value ends up nonzero, and
  2577. subsequent events occur as if the signal had come in just after the flag
  2578. was cleared. As long as the code handles both of these cases properly,
  2579. it can also handle a signal in the middle of clearing the flag. (This
  2580. is an example of the sort of reasoning you need to do to figure out
  2581. whether non-atomic usage is safe.)
  2582. Sometimes you can ensure uninterrupted access to one object by
  2583. protecting its use with another object, perhaps one whose type
  2584. guarantees atomicity. *Note Merged Signals::, for an example.
  2585. 
  2586. File: libc.info, Node: Interrupted Primitives, Next: Generating Signals, Prev: Defining Handlers, Up: Signal Handling
  2587. 24.5 Primitives Interrupted by Signals
  2588. ======================================
  2589. A signal can arrive and be handled while an I/O primitive such as ‘open’
  2590. or ‘read’ is waiting for an I/O device. If the signal handler returns,
  2591. the system faces the question: what should happen next?
  2592. POSIX specifies one approach: make the primitive fail right away.
  2593. The error code for this kind of failure is ‘EINTR’. This is flexible,
  2594. but usually inconvenient. Typically, POSIX applications that use signal
  2595. handlers must check for ‘EINTR’ after each library function that can
  2596. return it, in order to try the call again. Often programmers forget to
  2597. check, which is a common source of error.
  2598. The GNU C Library provides a convenient way to retry a call after a
  2599. temporary failure, with the macro ‘TEMP_FAILURE_RETRY’:
  2600. -- Macro: TEMP_FAILURE_RETRY (EXPRESSION)
  2601. This macro evaluates EXPRESSION once, and examines its value as
  2602. type ‘long int’. If the value equals ‘-1’, that indicates a
  2603. failure and ‘errno’ should be set to show what kind of failure. If
  2604. it fails and reports error code ‘EINTR’, ‘TEMP_FAILURE_RETRY’
  2605. evaluates it again, and over and over until the result is not a
  2606. temporary failure.
  2607. The value returned by ‘TEMP_FAILURE_RETRY’ is whatever value
  2608. EXPRESSION produced.
  2609. BSD avoids ‘EINTR’ entirely and provides a more convenient approach:
  2610. to restart the interrupted primitive, instead of making it fail. If you
  2611. choose this approach, you need not be concerned with ‘EINTR’.
  2612. You can choose either approach with the GNU C Library. If you use
  2613. ‘sigaction’ to establish a signal handler, you can specify how that
  2614. handler should behave. If you specify the ‘SA_RESTART’ flag, return
  2615. from that handler will resume a primitive; otherwise, return from that
  2616. handler will cause ‘EINTR’. *Note Flags for Sigaction::.
  2617. Another way to specify the choice is with the ‘siginterrupt’
  2618. function. *Note BSD Signal Handling::.
  2619. When you don’t specify with ‘sigaction’ or ‘siginterrupt’ what a
  2620. particular handler should do, it uses a default choice. The default
  2621. choice in the GNU C Library is to make primitives fail with ‘EINTR’.
  2622. The description of each primitive affected by this issue lists
  2623. ‘EINTR’ among the error codes it can return.
  2624. There is one situation where resumption never happens no matter which
  2625. choice you make: when a data-transfer function such as ‘read’ or ‘write’
  2626. is interrupted by a signal after transferring part of the data. In this
  2627. case, the function returns the number of bytes already transferred,
  2628. indicating partial success.
  2629. This might at first appear to cause unreliable behavior on
  2630. record-oriented devices (including datagram sockets; *note Datagrams::),
  2631. where splitting one ‘read’ or ‘write’ into two would read or write two
  2632. records. Actually, there is no problem, because interruption after a
  2633. partial transfer cannot happen on such devices; they always transfer an
  2634. entire record in one burst, with no waiting once data transfer has
  2635. started.
  2636. 
  2637. File: libc.info, Node: Generating Signals, Next: Blocking Signals, Prev: Interrupted Primitives, Up: Signal Handling
  2638. 24.6 Generating Signals
  2639. =======================
  2640. Besides signals that are generated as a result of a hardware trap or
  2641. interrupt, your program can explicitly send signals to itself or to
  2642. another process.
  2643. * Menu:
  2644. * Signaling Yourself:: A process can send a signal to itself.
  2645. * Signaling Another Process:: Send a signal to another process.
  2646. * Permission for kill:: Permission for using ‘kill’.
  2647. * Kill Example:: Using ‘kill’ for Communication.
  2648. 
  2649. File: libc.info, Node: Signaling Yourself, Next: Signaling Another Process, Up: Generating Signals
  2650. 24.6.1 Signaling Yourself
  2651. -------------------------
  2652. A process can send itself a signal with the ‘raise’ function. This
  2653. function is declared in ‘signal.h’.
  2654. -- Function: int raise (int SIGNUM)
  2655. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2656. Concepts::.
  2657. The ‘raise’ function sends the signal SIGNUM to the calling
  2658. process. It returns zero if successful and a nonzero value if it
  2659. fails. About the only reason for failure would be if the value of
  2660. SIGNUM is invalid.
  2661. -- Function: int gsignal (int SIGNUM)
  2662. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2663. Concepts::.
  2664. The ‘gsignal’ function does the same thing as ‘raise’; it is
  2665. provided only for compatibility with SVID.
  2666. One convenient use for ‘raise’ is to reproduce the default behavior
  2667. of a signal that you have trapped. For instance, suppose a user of your
  2668. program types the SUSP character (usually ‘C-z’; *note Special
  2669. Characters::) to send it an interactive stop signal (‘SIGTSTP’), and you
  2670. want to clean up some internal data buffers before stopping. You might
  2671. set this up like this:
  2672. #include <signal.h>
  2673. /* When a stop signal arrives, set the action back to the default
  2674. and then resend the signal after doing cleanup actions. */
  2675. void
  2676. tstp_handler (int sig)
  2677. {
  2678. signal (SIGTSTP, SIG_DFL);
  2679. /* Do cleanup actions here. */
  2680. ...
  2681. raise (SIGTSTP);
  2682. }
  2683. /* When the process is continued again, restore the signal handler. */
  2684. void
  2685. cont_handler (int sig)
  2686. {
  2687. signal (SIGCONT, cont_handler);
  2688. signal (SIGTSTP, tstp_handler);
  2689. }
  2690. /* Enable both handlers during program initialization. */
  2691. int
  2692. main (void)
  2693. {
  2694. signal (SIGCONT, cont_handler);
  2695. signal (SIGTSTP, tstp_handler);
  2696. ...
  2697. }
  2698. *Portability note:* ‘raise’ was invented by the ISO C committee.
  2699. Older systems may not support it, so using ‘kill’ may be more portable.
  2700. *Note Signaling Another Process::.
  2701. 
  2702. File: libc.info, Node: Signaling Another Process, Next: Permission for kill, Prev: Signaling Yourself, Up: Generating Signals
  2703. 24.6.2 Signaling Another Process
  2704. --------------------------------
  2705. The ‘kill’ function can be used to send a signal to another process. In
  2706. spite of its name, it can be used for a lot of things other than causing
  2707. a process to terminate. Some examples of situations where you might
  2708. want to send signals between processes are:
  2709. • A parent process starts a child to perform a task—perhaps having
  2710. the child running an infinite loop—and then terminates the child
  2711. when the task is no longer needed.
  2712. • A process executes as part of a group, and needs to terminate or
  2713. notify the other processes in the group when an error or other
  2714. event occurs.
  2715. • Two processes need to synchronize while working together.
  2716. This section assumes that you know a little bit about how processes
  2717. work. For more information on this subject, see *note Processes::.
  2718. The ‘kill’ function is declared in ‘signal.h’.
  2719. -- Function: int kill (pid_t PID, int SIGNUM)
  2720. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2721. Concepts::.
  2722. The ‘kill’ function sends the signal SIGNUM to the process or
  2723. process group specified by PID. Besides the signals listed in
  2724. *note Standard Signals::, SIGNUM can also have a value of zero to
  2725. check the validity of the PID.
  2726. The PID specifies the process or process group to receive the
  2727. signal:
  2728. ‘PID > 0’
  2729. The process whose identifier is PID. (On Linux, the signal is
  2730. sent to the entire process even if PID is a thread ID distinct
  2731. from the process ID.)
  2732. ‘PID == 0’
  2733. All processes in the same process group as the sender.
  2734. ‘PID < -1’
  2735. The process group whose identifier is −PID.
  2736. ‘PID == -1’
  2737. If the process is privileged, send the signal to all processes
  2738. except for some special system processes. Otherwise, send the
  2739. signal to all processes with the same effective user ID.
  2740. A process can send a signal to itself with a call like
  2741. ‘kill (getpid(), SIGNUM)’. If ‘kill’ is used by a process to send
  2742. a signal to itself, and the signal is not blocked, then ‘kill’
  2743. delivers at least one signal (which might be some other pending
  2744. unblocked signal instead of the signal SIGNUM) to that process
  2745. before it returns.
  2746. The return value from ‘kill’ is zero if the signal can be sent
  2747. successfully. Otherwise, no signal is sent, and a value of ‘-1’ is
  2748. returned. If PID specifies sending a signal to several processes,
  2749. ‘kill’ succeeds if it can send the signal to at least one of them.
  2750. There’s no way you can tell which of the processes got the signal
  2751. or whether all of them did.
  2752. The following ‘errno’ error conditions are defined for this
  2753. function:
  2754. ‘EINVAL’
  2755. The SIGNUM argument is an invalid or unsupported number.
  2756. ‘EPERM’
  2757. You do not have the privilege to send a signal to the process
  2758. or any of the processes in the process group named by PID.
  2759. ‘ESRCH’
  2760. The PID argument does not refer to an existing process or
  2761. group.
  2762. -- Function: int tgkill (pid_t PID, pid_t TID, int SIGNUM)
  2763. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2764. Concepts::.
  2765. The ‘tgkill’ function sends the signal SIGNUM to the thread or
  2766. process with ID TID, like the ‘kill’ function, but only if the
  2767. process ID of the thread TID is equal to PID. If the target thread
  2768. belongs to another process, the function fails with ‘ESRCH’.
  2769. The ‘tgkill’ function can be used to avoid sending a signal to a
  2770. thread in the wrong process if the caller ensures that the passed
  2771. PID value is not reused by the kernel (for example, if it is the
  2772. process ID of the current process, as returned by ‘getpid’).
  2773. -- Function: int killpg (int PGID, int SIGNUM)
  2774. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2775. Concepts::.
  2776. This is similar to ‘kill’, but sends signal SIGNUM to the process
  2777. group PGID. This function is provided for compatibility with BSD;
  2778. using ‘kill’ to do this is more portable.
  2779. As a simple example of ‘kill’, the call ‘kill (getpid (), SIG)’ has
  2780. the same effect as ‘raise (SIG)’.
  2781. 
  2782. File: libc.info, Node: Permission for kill, Next: Kill Example, Prev: Signaling Another Process, Up: Generating Signals
  2783. 24.6.3 Permission for using ‘kill’
  2784. ----------------------------------
  2785. There are restrictions that prevent you from using ‘kill’ to send
  2786. signals to any random process. These are intended to prevent antisocial
  2787. behavior such as arbitrarily killing off processes belonging to another
  2788. user. In typical use, ‘kill’ is used to pass signals between parent,
  2789. child, and sibling processes, and in these situations you normally do
  2790. have permission to send signals. The only common exception is when you
  2791. run a setuid program in a child process; if the program changes its real
  2792. UID as well as its effective UID, you may not have permission to send a
  2793. signal. The ‘su’ program does this.
  2794. Whether a process has permission to send a signal to another process
  2795. is determined by the user IDs of the two processes. This concept is
  2796. discussed in detail in *note Process Persona::.
  2797. Generally, for a process to be able to send a signal to another
  2798. process, either the sending process must belong to a privileged user
  2799. (like ‘root’), or the real or effective user ID of the sending process
  2800. must match the real or effective user ID of the receiving process. If
  2801. the receiving process has changed its effective user ID from the
  2802. set-user-ID mode bit on its process image file, then the owner of the
  2803. process image file is used in place of its current effective user ID. In
  2804. some implementations, a parent process might be able to send signals to
  2805. a child process even if the user ID’s don’t match, and other
  2806. implementations might enforce other restrictions.
  2807. The ‘SIGCONT’ signal is a special case. It can be sent if the sender
  2808. is part of the same session as the receiver, regardless of user IDs.
  2809. 
  2810. File: libc.info, Node: Kill Example, Prev: Permission for kill, Up: Generating Signals
  2811. 24.6.4 Using ‘kill’ for Communication
  2812. -------------------------------------
  2813. Here is a longer example showing how signals can be used for
  2814. interprocess communication. This is what the ‘SIGUSR1’ and ‘SIGUSR2’
  2815. signals are provided for. Since these signals are fatal by default, the
  2816. process that is supposed to receive them must trap them through ‘signal’
  2817. or ‘sigaction’.
  2818. In this example, a parent process forks a child process and then
  2819. waits for the child to complete its initialization. The child process
  2820. tells the parent when it is ready by sending it a ‘SIGUSR1’ signal,
  2821. using the ‘kill’ function.
  2822. #include <signal.h>
  2823. #include <stdio.h>
  2824. #include <sys/types.h>
  2825. #include <unistd.h>
  2826. /* When a ‘SIGUSR1’ signal arrives, set this variable. */
  2827. volatile sig_atomic_t usr_interrupt = 0;
  2828. void
  2829. synch_signal (int sig)
  2830. {
  2831. usr_interrupt = 1;
  2832. }
  2833. /* The child process executes this function. */
  2834. void
  2835. child_function (void)
  2836. {
  2837. /* Perform initialization. */
  2838. printf ("I'm here!!! My pid is %d.\n", (int) getpid ());
  2839. /* Let parent know you’re done. */
  2840. kill (getppid (), SIGUSR1);
  2841. /* Continue with execution. */
  2842. puts ("Bye, now....");
  2843. exit (0);
  2844. }
  2845. int
  2846. main (void)
  2847. {
  2848. struct sigaction usr_action;
  2849. sigset_t block_mask;
  2850. pid_t child_id;
  2851. /* Establish the signal handler. */
  2852. sigfillset (&block_mask);
  2853. usr_action.sa_handler = synch_signal;
  2854. usr_action.sa_mask = block_mask;
  2855. usr_action.sa_flags = 0;
  2856. sigaction (SIGUSR1, &usr_action, NULL);
  2857. /* Create the child process. */
  2858. child_id = fork ();
  2859. if (child_id == 0)
  2860. child_function (); /* Does not return. */
  2861. /* Busy wait for the child to send a signal. */
  2862. while (!usr_interrupt)
  2863. ;
  2864. /* Now continue execution. */
  2865. puts ("That's all, folks!");
  2866. return 0;
  2867. }
  2868. This example uses a busy wait, which is bad, because it wastes CPU
  2869. cycles that other programs could otherwise use. It is better to ask the
  2870. system to wait until the signal arrives. See the example in *note
  2871. Waiting for a Signal::.
  2872. 
  2873. File: libc.info, Node: Blocking Signals, Next: Waiting for a Signal, Prev: Generating Signals, Up: Signal Handling
  2874. 24.7 Blocking Signals
  2875. =====================
  2876. Blocking a signal means telling the operating system to hold it and
  2877. deliver it later. Generally, a program does not block signals
  2878. indefinitely—it might as well ignore them by setting their actions to
  2879. ‘SIG_IGN’. But it is useful to block signals briefly, to prevent them
  2880. from interrupting sensitive operations. For instance:
  2881. • You can use the ‘sigprocmask’ function to block signals while you
  2882. modify global variables that are also modified by the handlers for
  2883. these signals.
  2884. • You can set ‘sa_mask’ in your ‘sigaction’ call to block certain
  2885. signals while a particular signal handler runs. This way, the
  2886. signal handler can run without being interrupted itself by signals.
  2887. * Menu:
  2888. * Why Block:: The purpose of blocking signals.
  2889. * Signal Sets:: How to specify which signals to
  2890. block.
  2891. * Process Signal Mask:: Blocking delivery of signals to your
  2892. process during normal execution.
  2893. * Testing for Delivery:: Blocking to Test for Delivery of
  2894. a Signal.
  2895. * Blocking for Handler:: Blocking additional signals while a
  2896. handler is being run.
  2897. * Checking for Pending Signals:: Checking for Pending Signals
  2898. * Remembering a Signal:: How you can get almost the same
  2899. effect as blocking a signal, by
  2900. handling it and setting a flag
  2901. to be tested later.
  2902. 
  2903. File: libc.info, Node: Why Block, Next: Signal Sets, Up: Blocking Signals
  2904. 24.7.1 Why Blocking Signals is Useful
  2905. -------------------------------------
  2906. Temporary blocking of signals with ‘sigprocmask’ gives you a way to
  2907. prevent interrupts during critical parts of your code. If signals
  2908. arrive in that part of the program, they are delivered later, after you
  2909. unblock them.
  2910. One example where this is useful is for sharing data between a signal
  2911. handler and the rest of the program. If the type of the data is not
  2912. ‘sig_atomic_t’ (*note Atomic Data Access::), then the signal handler
  2913. could run when the rest of the program has only half finished reading or
  2914. writing the data. This would lead to confusing consequences.
  2915. To make the program reliable, you can prevent the signal handler from
  2916. running while the rest of the program is examining or modifying that
  2917. data—by blocking the appropriate signal around the parts of the program
  2918. that touch the data.
  2919. Blocking signals is also necessary when you want to perform a certain
  2920. action only if a signal has not arrived. Suppose that the handler for
  2921. the signal sets a flag of type ‘sig_atomic_t’; you would like to test
  2922. the flag and perform the action if the flag is not set. This is
  2923. unreliable. Suppose the signal is delivered immediately after you test
  2924. the flag, but before the consequent action: then the program will
  2925. perform the action even though the signal has arrived.
  2926. The only way to test reliably for whether a signal has yet arrived is
  2927. to test while the signal is blocked.
  2928. 
  2929. File: libc.info, Node: Signal Sets, Next: Process Signal Mask, Prev: Why Block, Up: Blocking Signals
  2930. 24.7.2 Signal Sets
  2931. ------------------
  2932. All of the signal blocking functions use a data structure called a
  2933. “signal set” to specify what signals are affected. Thus, every activity
  2934. involves two stages: creating the signal set, and then passing it as an
  2935. argument to a library function.
  2936. These facilities are declared in the header file ‘signal.h’.
  2937. -- Data Type: sigset_t
  2938. The ‘sigset_t’ data type is used to represent a signal set.
  2939. Internally, it may be implemented as either an integer or structure
  2940. type.
  2941. For portability, use only the functions described in this section
  2942. to initialize, change, and retrieve information from ‘sigset_t’
  2943. objects—don’t try to manipulate them directly.
  2944. There are two ways to initialize a signal set. You can initially
  2945. specify it to be empty with ‘sigemptyset’ and then add specified signals
  2946. individually. Or you can specify it to be full with ‘sigfillset’ and
  2947. then delete specified signals individually.
  2948. You must always initialize the signal set with one of these two
  2949. functions before using it in any other way. Don’t try to set all the
  2950. signals explicitly because the ‘sigset_t’ object might include some
  2951. other information (like a version field) that needs to be initialized as
  2952. well. (In addition, it’s not wise to put into your program an
  2953. assumption that the system has no signals aside from the ones you know
  2954. about.)
  2955. -- Function: int sigemptyset (sigset_t *SET)
  2956. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2957. Concepts::.
  2958. This function initializes the signal set SET to exclude all of the
  2959. defined signals. It always returns ‘0’.
  2960. -- Function: int sigfillset (sigset_t *SET)
  2961. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2962. Concepts::.
  2963. This function initializes the signal set SET to include all of the
  2964. defined signals. Again, the return value is ‘0’.
  2965. -- Function: int sigaddset (sigset_t *SET, int SIGNUM)
  2966. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2967. Concepts::.
  2968. This function adds the signal SIGNUM to the signal set SET. All
  2969. ‘sigaddset’ does is modify SET; it does not block or unblock any
  2970. signals.
  2971. The return value is ‘0’ on success and ‘-1’ on failure. The
  2972. following ‘errno’ error condition is defined for this function:
  2973. ‘EINVAL’
  2974. The SIGNUM argument doesn’t specify a valid signal.
  2975. -- Function: int sigdelset (sigset_t *SET, int SIGNUM)
  2976. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2977. Concepts::.
  2978. This function removes the signal SIGNUM from the signal set SET.
  2979. All ‘sigdelset’ does is modify SET; it does not block or unblock
  2980. any signals. The return value and error conditions are the same as
  2981. for ‘sigaddset’.
  2982. Finally, there is a function to test what signals are in a signal
  2983. set:
  2984. -- Function: int sigismember (const sigset_t *SET, int SIGNUM)
  2985. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2986. Concepts::.
  2987. The ‘sigismember’ function tests whether the signal SIGNUM is a
  2988. member of the signal set SET. It returns ‘1’ if the signal is in
  2989. the set, ‘0’ if not, and ‘-1’ if there is an error.
  2990. The following ‘errno’ error condition is defined for this function:
  2991. ‘EINVAL’
  2992. The SIGNUM argument doesn’t specify a valid signal.
  2993. 
  2994. File: libc.info, Node: Process Signal Mask, Next: Testing for Delivery, Prev: Signal Sets, Up: Blocking Signals
  2995. 24.7.3 Process Signal Mask
  2996. --------------------------
  2997. The collection of signals that are currently blocked is called the
  2998. “signal mask”. Each process has its own signal mask. When you create a
  2999. new process (*note Creating a Process::), it inherits its parent’s mask.
  3000. You can block or unblock signals with total flexibility by modifying the
  3001. signal mask.
  3002. The prototype for the ‘sigprocmask’ function is in ‘signal.h’.
  3003. Note that you must not use ‘sigprocmask’ in multi-threaded processes,
  3004. because each thread has its own signal mask and there is no single
  3005. process signal mask. According to POSIX, the behavior of ‘sigprocmask’
  3006. in a multi-threaded process is “unspecified”. Instead, use
  3007. ‘pthread_sigmask’.
  3008. -- Function: int sigprocmask (int HOW, const sigset_t *restrict SET,
  3009. sigset_t *restrict OLDSET)
  3010. Preliminary: | MT-Unsafe race:sigprocmask/bsd(SIG_UNBLOCK) |
  3011. AS-Unsafe lock/hurd | AC-Unsafe lock/hurd | *Note POSIX Safety
  3012. Concepts::.
  3013. The ‘sigprocmask’ function is used to examine or change the calling
  3014. process’s signal mask. The HOW argument determines how the signal
  3015. mask is changed, and must be one of the following values:
  3016. ‘SIG_BLOCK’
  3017. Block the signals in ‘set’—add them to the existing mask. In
  3018. other words, the new mask is the union of the existing mask
  3019. and SET.
  3020. ‘SIG_UNBLOCK’
  3021. Unblock the signals in SET—remove them from the existing mask.
  3022. ‘SIG_SETMASK’
  3023. Use SET for the mask; ignore the previous value of the mask.
  3024. The last argument, OLDSET, is used to return information about the
  3025. old process signal mask. If you just want to change the mask
  3026. without looking at it, pass a null pointer as the OLDSET argument.
  3027. Similarly, if you want to know what’s in the mask without changing
  3028. it, pass a null pointer for SET (in this case the HOW argument is
  3029. not significant). The OLDSET argument is often used to remember
  3030. the previous signal mask in order to restore it later. (Since the
  3031. signal mask is inherited over ‘fork’ and ‘exec’ calls, you can’t
  3032. predict what its contents are when your program starts running.)
  3033. If invoking ‘sigprocmask’ causes any pending signals to be
  3034. unblocked, at least one of those signals is delivered to the
  3035. process before ‘sigprocmask’ returns. The order in which pending
  3036. signals are delivered is not specified, but you can control the
  3037. order explicitly by making multiple ‘sigprocmask’ calls to unblock
  3038. various signals one at a time.
  3039. The ‘sigprocmask’ function returns ‘0’ if successful, and ‘-1’ to
  3040. indicate an error. The following ‘errno’ error conditions are
  3041. defined for this function:
  3042. ‘EINVAL’
  3043. The HOW argument is invalid.
  3044. You can’t block the ‘SIGKILL’ and ‘SIGSTOP’ signals, but if the
  3045. signal set includes these, ‘sigprocmask’ just ignores them instead
  3046. of returning an error status.
  3047. Remember, too, that blocking program error signals such as ‘SIGFPE’
  3048. leads to undesirable results for signals generated by an actual
  3049. program error (as opposed to signals sent with ‘raise’ or ‘kill’).
  3050. This is because your program may be too broken to be able to
  3051. continue executing to a point where the signal is unblocked again.
  3052. *Note Program Error Signals::.
  3053. 
  3054. File: libc.info, Node: Testing for Delivery, Next: Blocking for Handler, Prev: Process Signal Mask, Up: Blocking Signals
  3055. 24.7.4 Blocking to Test for Delivery of a Signal
  3056. ------------------------------------------------
  3057. Now for a simple example. Suppose you establish a handler for ‘SIGALRM’
  3058. signals that sets a flag whenever a signal arrives, and your main
  3059. program checks this flag from time to time and then resets it. You can
  3060. prevent additional ‘SIGALRM’ signals from arriving in the meantime by
  3061. wrapping the critical part of the code with calls to ‘sigprocmask’, like
  3062. this:
  3063. /* This variable is set by the SIGALRM signal handler. */
  3064. volatile sig_atomic_t flag = 0;
  3065. int
  3066. main (void)
  3067. {
  3068. sigset_t block_alarm;
  3069. ...
  3070. /* Initialize the signal mask. */
  3071. sigemptyset (&block_alarm);
  3072. sigaddset (&block_alarm, SIGALRM);
  3073. while (1)
  3074. {
  3075. /* Check if a signal has arrived; if so, reset the flag. */
  3076. sigprocmask (SIG_BLOCK, &block_alarm, NULL);
  3077. if (flag)
  3078. {
  3079. ACTIONS-IF-NOT-ARRIVED
  3080. flag = 0;
  3081. }
  3082. sigprocmask (SIG_UNBLOCK, &block_alarm, NULL);
  3083. ...
  3084. }
  3085. }
  3086. 
  3087. File: libc.info, Node: Blocking for Handler, Next: Checking for Pending Signals, Prev: Testing for Delivery, Up: Blocking Signals
  3088. 24.7.5 Blocking Signals for a Handler
  3089. -------------------------------------
  3090. When a signal handler is invoked, you usually want it to be able to
  3091. finish without being interrupted by another signal. From the moment the
  3092. handler starts until the moment it finishes, you must block signals that
  3093. might confuse it or corrupt its data.
  3094. When a handler function is invoked on a signal, that signal is
  3095. automatically blocked (in addition to any other signals that are already
  3096. in the process’s signal mask) during the time the handler is running.
  3097. If you set up a handler for ‘SIGTSTP’, for instance, then the arrival of
  3098. that signal forces further ‘SIGTSTP’ signals to wait during the
  3099. execution of the handler.
  3100. However, by default, other kinds of signals are not blocked; they can
  3101. arrive during handler execution.
  3102. The reliable way to block other kinds of signals during the execution
  3103. of the handler is to use the ‘sa_mask’ member of the ‘sigaction’
  3104. structure.
  3105. Here is an example:
  3106. #include <signal.h>
  3107. #include <stddef.h>
  3108. void catch_stop ();
  3109. void
  3110. install_handler (void)
  3111. {
  3112. struct sigaction setup_action;
  3113. sigset_t block_mask;
  3114. sigemptyset (&block_mask);
  3115. /* Block other terminal-generated signals while handler runs. */
  3116. sigaddset (&block_mask, SIGINT);
  3117. sigaddset (&block_mask, SIGQUIT);
  3118. setup_action.sa_handler = catch_stop;
  3119. setup_action.sa_mask = block_mask;
  3120. setup_action.sa_flags = 0;
  3121. sigaction (SIGTSTP, &setup_action, NULL);
  3122. }
  3123. This is more reliable than blocking the other signals explicitly in
  3124. the code for the handler. If you block signals explicitly in the
  3125. handler, you can’t avoid at least a short interval at the beginning of
  3126. the handler where they are not yet blocked.
  3127. You cannot remove signals from the process’s current mask using this
  3128. mechanism. However, you can make calls to ‘sigprocmask’ within your
  3129. handler to block or unblock signals as you wish.
  3130. In any case, when the handler returns, the system restores the mask
  3131. that was in place before the handler was entered. If any signals that
  3132. become unblocked by this restoration are pending, the process will
  3133. receive those signals immediately, before returning to the code that was
  3134. interrupted.
  3135. 
  3136. File: libc.info, Node: Checking for Pending Signals, Next: Remembering a Signal, Prev: Blocking for Handler, Up: Blocking Signals
  3137. 24.7.6 Checking for Pending Signals
  3138. -----------------------------------
  3139. You can find out which signals are pending at any time by calling
  3140. ‘sigpending’. This function is declared in ‘signal.h’.
  3141. -- Function: int sigpending (sigset_t *SET)
  3142. Preliminary: | MT-Safe | AS-Unsafe lock/hurd | AC-Unsafe lock/hurd
  3143. | *Note POSIX Safety Concepts::.
  3144. The ‘sigpending’ function stores information about pending signals
  3145. in SET. If there is a pending signal that is blocked from
  3146. delivery, then that signal is a member of the returned set. (You
  3147. can test whether a particular signal is a member of this set using
  3148. ‘sigismember’; see *note Signal Sets::.)
  3149. The return value is ‘0’ if successful, and ‘-1’ on failure.
  3150. Testing whether a signal is pending is not often useful. Testing
  3151. when that signal is not blocked is almost certainly bad design.
  3152. Here is an example.
  3153. #include <signal.h>
  3154. #include <stddef.h>
  3155. sigset_t base_mask, waiting_mask;
  3156. sigemptyset (&base_mask);
  3157. sigaddset (&base_mask, SIGINT);
  3158. sigaddset (&base_mask, SIGTSTP);
  3159. /* Block user interrupts while doing other processing. */
  3160. sigprocmask (SIG_SETMASK, &base_mask, NULL);
  3161. ...
  3162. /* After a while, check to see whether any signals are pending. */
  3163. sigpending (&waiting_mask);
  3164. if (sigismember (&waiting_mask, SIGINT)) {
  3165. /* User has tried to kill the process. */
  3166. }
  3167. else if (sigismember (&waiting_mask, SIGTSTP)) {
  3168. /* User has tried to stop the process. */
  3169. }
  3170. Remember that if there is a particular signal pending for your
  3171. process, additional signals of that same type that arrive in the
  3172. meantime might be discarded. For example, if a ‘SIGINT’ signal is
  3173. pending when another ‘SIGINT’ signal arrives, your program will probably
  3174. only see one of them when you unblock this signal.
  3175. *Portability Note:* The ‘sigpending’ function is new in POSIX.1.
  3176. Older systems have no equivalent facility.
  3177. 
  3178. File: libc.info, Node: Remembering a Signal, Prev: Checking for Pending Signals, Up: Blocking Signals
  3179. 24.7.7 Remembering a Signal to Act On Later
  3180. -------------------------------------------
  3181. Instead of blocking a signal using the library facilities, you can get
  3182. almost the same results by making the handler set a flag to be tested
  3183. later, when you “unblock”. Here is an example:
  3184. /* If this flag is nonzero, don’t handle the signal right away. */
  3185. volatile sig_atomic_t signal_pending;
  3186. /* This is nonzero if a signal arrived and was not handled. */
  3187. volatile sig_atomic_t defer_signal;
  3188. void
  3189. handler (int signum)
  3190. {
  3191. if (defer_signal)
  3192. signal_pending = signum;
  3193. else
  3194. ... /* “Really” handle the signal. */
  3195. }
  3196. ...
  3197. void
  3198. update_mumble (int frob)
  3199. {
  3200. /* Prevent signals from having immediate effect. */
  3201. defer_signal++;
  3202. /* Now update ‘mumble’, without worrying about interruption. */
  3203. mumble.a = 1;
  3204. mumble.b = hack ();
  3205. mumble.c = frob;
  3206. /* We have updated ‘mumble’. Handle any signal that came in. */
  3207. defer_signal--;
  3208. if (defer_signal == 0 && signal_pending != 0)
  3209. raise (signal_pending);
  3210. }
  3211. Note how the particular signal that arrives is stored in
  3212. ‘signal_pending’. That way, we can handle several types of inconvenient
  3213. signals with the same mechanism.
  3214. We increment and decrement ‘defer_signal’ so that nested critical
  3215. sections will work properly; thus, if ‘update_mumble’ were called with
  3216. ‘signal_pending’ already nonzero, signals would be deferred not only
  3217. within ‘update_mumble’, but also within the caller. This is also why we
  3218. do not check ‘signal_pending’ if ‘defer_signal’ is still nonzero.
  3219. The incrementing and decrementing of ‘defer_signal’ each require more
  3220. than one instruction; it is possible for a signal to happen in the
  3221. middle. But that does not cause any problem. If the signal happens
  3222. early enough to see the value from before the increment or decrement,
  3223. that is equivalent to a signal which came before the beginning of the
  3224. increment or decrement, which is a case that works properly.
  3225. It is absolutely vital to decrement ‘defer_signal’ before testing
  3226. ‘signal_pending’, because this avoids a subtle bug. If we did these
  3227. things in the other order, like this,
  3228. if (defer_signal == 1 && signal_pending != 0)
  3229. raise (signal_pending);
  3230. defer_signal--;
  3231. then a signal arriving in between the ‘if’ statement and the decrement
  3232. would be effectively “lost” for an indefinite amount of time. The
  3233. handler would merely set ‘defer_signal’, but the program having already
  3234. tested this variable, it would not test the variable again.
  3235. Bugs like these are called “timing errors”. They are especially bad
  3236. because they happen only rarely and are nearly impossible to reproduce.
  3237. You can’t expect to find them with a debugger as you would find a
  3238. reproducible bug. So it is worth being especially careful to avoid
  3239. them.
  3240. (You would not be tempted to write the code in this order, given the
  3241. use of ‘defer_signal’ as a counter which must be tested along with
  3242. ‘signal_pending’. After all, testing for zero is cleaner than testing
  3243. for one. But if you did not use ‘defer_signal’ as a counter, and gave
  3244. it values of zero and one only, then either order might seem equally
  3245. simple. This is a further advantage of using a counter for
  3246. ‘defer_signal’: it will reduce the chance you will write the code in the
  3247. wrong order and create a subtle bug.)
  3248. 
  3249. File: libc.info, Node: Waiting for a Signal, Next: Signal Stack, Prev: Blocking Signals, Up: Signal Handling
  3250. 24.8 Waiting for a Signal
  3251. =========================
  3252. If your program is driven by external events, or uses signals for
  3253. synchronization, then when it has nothing to do it should probably wait
  3254. until a signal arrives.
  3255. * Menu:
  3256. * Using Pause:: The simple way, using ‘pause’.
  3257. * Pause Problems:: Why the simple way is often not very good.
  3258. * Sigsuspend:: Reliably waiting for a specific signal.
  3259. 
  3260. File: libc.info, Node: Using Pause, Next: Pause Problems, Up: Waiting for a Signal
  3261. 24.8.1 Using ‘pause’
  3262. --------------------
  3263. The simple way to wait until a signal arrives is to call ‘pause’.
  3264. Please read about its disadvantages, in the following section, before
  3265. you use it.
  3266. -- Function: int pause (void)
  3267. Preliminary: | MT-Unsafe race:sigprocmask/!bsd!linux | AS-Unsafe
  3268. lock/hurd | AC-Unsafe lock/hurd | *Note POSIX Safety Concepts::.
  3269. The ‘pause’ function suspends program execution until a signal
  3270. arrives whose action is either to execute a handler function, or to
  3271. terminate the process.
  3272. If the signal causes a handler function to be executed, then
  3273. ‘pause’ returns. This is considered an unsuccessful return (since
  3274. “successful” behavior would be to suspend the program forever), so
  3275. the return value is ‘-1’. Even if you specify that other
  3276. primitives should resume when a system handler returns (*note
  3277. Interrupted Primitives::), this has no effect on ‘pause’; it always
  3278. fails when a signal is handled.
  3279. The following ‘errno’ error conditions are defined for this
  3280. function:
  3281. ‘EINTR’
  3282. The function was interrupted by delivery of a signal.
  3283. If the signal causes program termination, ‘pause’ doesn’t return
  3284. (obviously).
  3285. This function is a cancellation point in multithreaded programs.
  3286. This is a problem if the thread allocates some resources (like
  3287. memory, file descriptors, semaphores or whatever) at the time
  3288. ‘pause’ is called. If the thread gets cancelled these resources
  3289. stay allocated until the program ends. To avoid this calls to
  3290. ‘pause’ should be protected using cancellation handlers.
  3291. The ‘pause’ function is declared in ‘unistd.h’.
  3292. 
  3293. File: libc.info, Node: Pause Problems, Next: Sigsuspend, Prev: Using Pause, Up: Waiting for a Signal
  3294. 24.8.2 Problems with ‘pause’
  3295. ----------------------------
  3296. The simplicity of ‘pause’ can conceal serious timing errors that can
  3297. make a program hang mysteriously.
  3298. It is safe to use ‘pause’ if the real work of your program is done by
  3299. the signal handlers themselves, and the “main program” does nothing but
  3300. call ‘pause’. Each time a signal is delivered, the handler will do the
  3301. next batch of work that is to be done, and then return, so that the main
  3302. loop of the program can call ‘pause’ again.
  3303. You can’t safely use ‘pause’ to wait until one more signal arrives,
  3304. and then resume real work. Even if you arrange for the signal handler
  3305. to cooperate by setting a flag, you still can’t use ‘pause’ reliably.
  3306. Here is an example of this problem:
  3307. /* ‘usr_interrupt’ is set by the signal handler. */
  3308. if (!usr_interrupt)
  3309. pause ();
  3310. /* Do work once the signal arrives. */
  3311. ...
  3312. This has a bug: the signal could arrive after the variable
  3313. ‘usr_interrupt’ is checked, but before the call to ‘pause’. If no
  3314. further signals arrive, the process would never wake up again.
  3315. You can put an upper limit on the excess waiting by using ‘sleep’ in
  3316. a loop, instead of using ‘pause’. (*Note Sleeping::, for more about
  3317. ‘sleep’.) Here is what this looks like:
  3318. /* ‘usr_interrupt’ is set by the signal handler.
  3319. while (!usr_interrupt)
  3320. sleep (1);
  3321. /* Do work once the signal arrives. */
  3322. ...
  3323. For some purposes, that is good enough. But with a little more
  3324. complexity, you can wait reliably until a particular signal handler is
  3325. run, using ‘sigsuspend’. *Note Sigsuspend::.
  3326. 
  3327. File: libc.info, Node: Sigsuspend, Prev: Pause Problems, Up: Waiting for a Signal
  3328. 24.8.3 Using ‘sigsuspend’
  3329. -------------------------
  3330. The clean and reliable way to wait for a signal to arrive is to block it
  3331. and then use ‘sigsuspend’. By using ‘sigsuspend’ in a loop, you can
  3332. wait for certain kinds of signals, while letting other kinds of signals
  3333. be handled by their handlers.
  3334. -- Function: int sigsuspend (const sigset_t *SET)
  3335. Preliminary: | MT-Unsafe race:sigprocmask/!bsd!linux | AS-Unsafe
  3336. lock/hurd | AC-Unsafe lock/hurd | *Note POSIX Safety Concepts::.
  3337. This function replaces the process’s signal mask with SET and then
  3338. suspends the process until a signal is delivered whose action is
  3339. either to terminate the process or invoke a signal handling
  3340. function. In other words, the program is effectively suspended
  3341. until one of the signals that is not a member of SET arrives.
  3342. If the process is woken up by delivery of a signal that invokes a
  3343. handler function, and the handler function returns, then
  3344. ‘sigsuspend’ also returns.
  3345. The mask remains SET only as long as ‘sigsuspend’ is waiting. The
  3346. function ‘sigsuspend’ always restores the previous signal mask when
  3347. it returns.
  3348. The return value and error conditions are the same as for ‘pause’.
  3349. With ‘sigsuspend’, you can replace the ‘pause’ or ‘sleep’ loop in the
  3350. previous section with something completely reliable:
  3351. sigset_t mask, oldmask;
  3352. ...
  3353. /* Set up the mask of signals to temporarily block. */
  3354. sigemptyset (&mask);
  3355. sigaddset (&mask, SIGUSR1);
  3356. ...
  3357. /* Wait for a signal to arrive. */
  3358. sigprocmask (SIG_BLOCK, &mask, &oldmask);
  3359. while (!usr_interrupt)
  3360. sigsuspend (&oldmask);
  3361. sigprocmask (SIG_UNBLOCK, &mask, NULL);
  3362. This last piece of code is a little tricky. The key point to
  3363. remember here is that when ‘sigsuspend’ returns, it resets the process’s
  3364. signal mask to the original value, the value from before the call to
  3365. ‘sigsuspend’—in this case, the ‘SIGUSR1’ signal is once again blocked.
  3366. The second call to ‘sigprocmask’ is necessary to explicitly unblock this
  3367. signal.
  3368. One other point: you may be wondering why the ‘while’ loop is
  3369. necessary at all, since the program is apparently only waiting for one
  3370. ‘SIGUSR1’ signal. The answer is that the mask passed to ‘sigsuspend’
  3371. permits the process to be woken up by the delivery of other kinds of
  3372. signals, as well—for example, job control signals. If the process is
  3373. woken up by a signal that doesn’t set ‘usr_interrupt’, it just suspends
  3374. itself again until the “right” kind of signal eventually arrives.
  3375. This technique takes a few more lines of preparation, but that is
  3376. needed just once for each kind of wait criterion you want to use. The
  3377. code that actually waits is just four lines.
  3378. 
  3379. File: libc.info, Node: Signal Stack, Next: BSD Signal Handling, Prev: Waiting for a Signal, Up: Signal Handling
  3380. 24.9 Using a Separate Signal Stack
  3381. ==================================
  3382. A signal stack is a special area of memory to be used as the execution
  3383. stack during signal handlers. It should be fairly large, to avoid any
  3384. danger that it will overflow in turn; the macro ‘SIGSTKSZ’ is defined to
  3385. a canonical size for signal stacks. You can use ‘malloc’ to allocate
  3386. the space for the stack. Then call ‘sigaltstack’ or ‘sigstack’ to tell
  3387. the system to use that space for the signal stack.
  3388. You don’t need to write signal handlers differently in order to use a
  3389. signal stack. Switching from one stack to the other happens
  3390. automatically. (Some non-GNU debuggers on some machines may get
  3391. confused if you examine a stack trace while a handler that uses the
  3392. signal stack is running.)
  3393. There are two interfaces for telling the system to use a separate
  3394. signal stack. ‘sigstack’ is the older interface, which comes from 4.2
  3395. BSD. ‘sigaltstack’ is the newer interface, and comes from 4.4 BSD. The
  3396. ‘sigaltstack’ interface has the advantage that it does not require your
  3397. program to know which direction the stack grows, which depends on the
  3398. specific machine and operating system.
  3399. -- Data Type: stack_t
  3400. This structure describes a signal stack. It contains the following
  3401. members:
  3402. ‘void *ss_sp’
  3403. This points to the base of the signal stack.
  3404. ‘size_t ss_size’
  3405. This is the size (in bytes) of the signal stack which ‘ss_sp’
  3406. points to. You should set this to however much space you
  3407. allocated for the stack.
  3408. There are two macros defined in ‘signal.h’ that you should use
  3409. in calculating this size:
  3410. ‘SIGSTKSZ’
  3411. This is the canonical size for a signal stack. It is
  3412. judged to be sufficient for normal uses.
  3413. ‘MINSIGSTKSZ’
  3414. This is the amount of signal stack space the operating
  3415. system needs just to implement signal delivery. The size
  3416. of a signal stack *must* be greater than this.
  3417. For most cases, just using ‘SIGSTKSZ’ for ‘ss_size’ is
  3418. sufficient. But if you know how much stack space your
  3419. program’s signal handlers will need, you may want to use
  3420. a different size. In this case, you should allocate
  3421. ‘MINSIGSTKSZ’ additional bytes for the signal stack and
  3422. increase ‘ss_size’ accordingly.
  3423. ‘int ss_flags’
  3424. This field contains the bitwise OR of these flags:
  3425. ‘SS_DISABLE’
  3426. This tells the system that it should not use the signal
  3427. stack.
  3428. ‘SS_ONSTACK’
  3429. This is set by the system, and indicates that the signal
  3430. stack is currently in use. If this bit is not set, then
  3431. signals will be delivered on the normal user stack.
  3432. -- Function: int sigaltstack (const stack_t *restrict STACK, stack_t
  3433. *restrict OLDSTACK)
  3434. Preliminary: | MT-Safe | AS-Unsafe lock/hurd | AC-Unsafe lock/hurd
  3435. | *Note POSIX Safety Concepts::.
  3436. The ‘sigaltstack’ function specifies an alternate stack for use
  3437. during signal handling. When a signal is received by the process
  3438. and its action indicates that the signal stack is used, the system
  3439. arranges a switch to the currently installed signal stack while the
  3440. handler for that signal is executed.
  3441. If OLDSTACK is not a null pointer, information about the currently
  3442. installed signal stack is returned in the location it points to.
  3443. If STACK is not a null pointer, then this is installed as the new
  3444. stack for use by signal handlers.
  3445. The return value is ‘0’ on success and ‘-1’ on failure. If
  3446. ‘sigaltstack’ fails, it sets ‘errno’ to one of these values:
  3447. ‘EINVAL’
  3448. You tried to disable a stack that was in fact currently in
  3449. use.
  3450. ‘ENOMEM’
  3451. The size of the alternate stack was too small. It must be
  3452. greater than ‘MINSIGSTKSZ’.
  3453. Here is the older ‘sigstack’ interface. You should use ‘sigaltstack’
  3454. instead on systems that have it.
  3455. -- Data Type: struct sigstack
  3456. This structure describes a signal stack. It contains the following
  3457. members:
  3458. ‘void *ss_sp’
  3459. This is the stack pointer. If the stack grows downwards on
  3460. your machine, this should point to the top of the area you
  3461. allocated. If the stack grows upwards, it should point to the
  3462. bottom.
  3463. ‘int ss_onstack’
  3464. This field is true if the process is currently using this
  3465. stack.
  3466. -- Function: int sigstack (struct sigstack *STACK, struct sigstack
  3467. *OLDSTACK)
  3468. Preliminary: | MT-Safe | AS-Unsafe lock/hurd | AC-Unsafe lock/hurd
  3469. | *Note POSIX Safety Concepts::.
  3470. The ‘sigstack’ function specifies an alternate stack for use during
  3471. signal handling. When a signal is received by the process and its
  3472. action indicates that the signal stack is used, the system arranges
  3473. a switch to the currently installed signal stack while the handler
  3474. for that signal is executed.
  3475. If OLDSTACK is not a null pointer, information about the currently
  3476. installed signal stack is returned in the location it points to.
  3477. If STACK is not a null pointer, then this is installed as the new
  3478. stack for use by signal handlers.
  3479. The return value is ‘0’ on success and ‘-1’ on failure.
  3480. 
  3481. File: libc.info, Node: BSD Signal Handling, Prev: Signal Stack, Up: Signal Handling
  3482. 24.10 BSD Signal Handling
  3483. =========================
  3484. This section describes alternative signal handling functions derived
  3485. from BSD Unix. These facilities were an advance, in their time; today,
  3486. they are mostly obsolete, and supported mainly for compatibility with
  3487. BSD Unix.
  3488. There are many similarities between the BSD and POSIX signal handling
  3489. facilities, because the POSIX facilities were inspired by the BSD
  3490. facilities. Besides having different names for all the functions to
  3491. avoid conflicts, the main difference between the two is that BSD Unix
  3492. represents signal masks as an ‘int’ bit mask, rather than as a
  3493. ‘sigset_t’ object.
  3494. The BSD facilities are declared in ‘signal.h’.
  3495. -- Function: int siginterrupt (int SIGNUM, int FAILFLAG)
  3496. Preliminary: | MT-Unsafe const:sigintr | AS-Unsafe | AC-Unsafe
  3497. corrupt | *Note POSIX Safety Concepts::.
  3498. This function specifies which approach to use when certain
  3499. primitives are interrupted by handling signal SIGNUM. If FAILFLAG
  3500. is false, signal SIGNUM restarts primitives. If FAILFLAG is true,
  3501. handling SIGNUM causes these primitives to fail with error code
  3502. ‘EINTR’. *Note Interrupted Primitives::.
  3503. This function has been replaced by the ‘SA_RESTART’ flag of the
  3504. ‘sigaction’ function. *Note Advanced Signal Handling::.
  3505. -- Macro: int sigmask (int SIGNUM)
  3506. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3507. Concepts::.
  3508. This macro returns a signal mask that has the bit for signal SIGNUM
  3509. set. You can bitwise-OR the results of several calls to ‘sigmask’
  3510. together to specify more than one signal. For example,
  3511. (sigmask (SIGTSTP) | sigmask (SIGSTOP)
  3512. | sigmask (SIGTTIN) | sigmask (SIGTTOU))
  3513. specifies a mask that includes all the job-control stop signals.
  3514. This macro has been replaced by the ‘sigset_t’ type and the
  3515. associated signal set manipulation functions. *Note Signal Sets::.
  3516. -- Function: int sigblock (int MASK)
  3517. Preliminary: | MT-Safe | AS-Unsafe lock/hurd | AC-Unsafe lock/hurd
  3518. | *Note POSIX Safety Concepts::.
  3519. This function is equivalent to ‘sigprocmask’ (*note Process Signal
  3520. Mask::) with a HOW argument of ‘SIG_BLOCK’: it adds the signals
  3521. specified by MASK to the calling process’s set of blocked signals.
  3522. The return value is the previous set of blocked signals.
  3523. -- Function: int sigsetmask (int MASK)
  3524. Preliminary: | MT-Safe | AS-Unsafe lock/hurd | AC-Unsafe lock/hurd
  3525. | *Note POSIX Safety Concepts::.
  3526. This function is equivalent to ‘sigprocmask’ (*note Process Signal
  3527. Mask::) with a HOW argument of ‘SIG_SETMASK’: it sets the calling
  3528. process’s signal mask to MASK. The return value is the previous
  3529. set of blocked signals.
  3530. -- Function: int sigpause (int MASK)
  3531. Preliminary: | MT-Unsafe race:sigprocmask/!bsd!linux | AS-Unsafe
  3532. lock/hurd | AC-Unsafe lock/hurd | *Note POSIX Safety Concepts::.
  3533. This function is the equivalent of ‘sigsuspend’ (*note Waiting for
  3534. a Signal::): it sets the calling process’s signal mask to MASK, and
  3535. waits for a signal to arrive. On return the previous set of
  3536. blocked signals is restored.
  3537. 
  3538. File: libc.info, Node: Program Basics, Next: Processes, Prev: Signal Handling, Up: Top
  3539. 25 The Basic Program/System Interface
  3540. *************************************
  3541. “Processes” are the primitive units for allocation of system resources.
  3542. Each process has its own address space and (usually) one thread of
  3543. control. A process executes a program; you can have multiple processes
  3544. executing the same program, but each process has its own copy of the
  3545. program within its own address space and executes it independently of
  3546. the other copies. Though it may have multiple threads of control within
  3547. the same program and a program may be composed of multiple logically
  3548. separate modules, a process always executes exactly one program.
  3549. Note that we are using a specific definition of “program” for the
  3550. purposes of this manual, which corresponds to a common definition in the
  3551. context of Unix systems. In popular usage, “program” enjoys a much
  3552. broader definition; it can refer for example to a system’s kernel, an
  3553. editor macro, a complex package of software, or a discrete section of
  3554. code executing within a process.
  3555. Writing the program is what this manual is all about. This chapter
  3556. explains the most basic interface between your program and the system
  3557. that runs, or calls, it. This includes passing of parameters (arguments
  3558. and environment) from the system, requesting basic services from the
  3559. system, and telling the system the program is done.
  3560. A program starts another program with the ‘exec’ family of system
  3561. calls. This chapter looks at program startup from the execee’s point of
  3562. view. To see the event from the execor’s point of view, see *note
  3563. Executing a File::.
  3564. * Menu:
  3565. * Program Arguments:: Parsing your program’s command-line arguments
  3566. * Environment Variables:: Less direct parameters affecting your program
  3567. * Auxiliary Vector:: Least direct parameters affecting your program
  3568. * System Calls:: Requesting service from the system
  3569. * Program Termination:: Telling the system you’re done; return status
  3570. 
  3571. File: libc.info, Node: Program Arguments, Next: Environment Variables, Up: Program Basics
  3572. 25.1 Program Arguments
  3573. ======================
  3574. The system starts a C program by calling the function ‘main’. It is up
  3575. to you to write a function named ‘main’—otherwise, you won’t even be
  3576. able to link your program without errors.
  3577. In ISO C you can define ‘main’ either to take no arguments, or to
  3578. take two arguments that represent the command line arguments to the
  3579. program, like this:
  3580. int main (int ARGC, char *ARGV[])
  3581. The command line arguments are the whitespace-separated tokens given
  3582. in the shell command used to invoke the program; thus, in ‘cat foo bar’,
  3583. the arguments are ‘foo’ and ‘bar’. The only way a program can look at
  3584. its command line arguments is via the arguments of ‘main’. If ‘main’
  3585. doesn’t take arguments, then you cannot get at the command line.
  3586. The value of the ARGC argument is the number of command line
  3587. arguments. The ARGV argument is a vector of C strings; its elements are
  3588. the individual command line argument strings. The file name of the
  3589. program being run is also included in the vector as the first element;
  3590. the value of ARGC counts this element. A null pointer always follows
  3591. the last element: ‘ARGV[ARGC]’ is this null pointer.
  3592. For the command ‘cat foo bar’, ARGC is 3 and ARGV has three elements,
  3593. ‘"cat"’, ‘"foo"’ and ‘"bar"’.
  3594. In Unix systems you can define ‘main’ a third way, using three
  3595. arguments:
  3596. int main (int ARGC, char *ARGV[], char *ENVP[])
  3597. The first two arguments are just the same. The third argument ENVP
  3598. gives the program’s environment; it is the same as the value of
  3599. ‘environ’. *Note Environment Variables::. POSIX.1 does not allow this
  3600. three-argument form, so to be portable it is best to write ‘main’ to
  3601. take two arguments, and use the value of ‘environ’.
  3602. * Menu:
  3603. * Argument Syntax:: By convention, options start with a hyphen.
  3604. * Parsing Program Arguments:: Ways to parse program options and arguments.
  3605. 
  3606. File: libc.info, Node: Argument Syntax, Next: Parsing Program Arguments, Up: Program Arguments
  3607. 25.1.1 Program Argument Syntax Conventions
  3608. ------------------------------------------
  3609. POSIX recommends these conventions for command line arguments. ‘getopt’
  3610. (*note Getopt::) and ‘argp_parse’ (*note Argp::) make it easy to
  3611. implement them.
  3612. • Arguments are options if they begin with a hyphen delimiter (‘-’).
  3613. • Multiple options may follow a hyphen delimiter in a single token if
  3614. the options do not take arguments. Thus, ‘-abc’ is equivalent to
  3615. ‘-a -b -c’.
  3616. • Option names are single alphanumeric characters (as for ‘isalnum’;
  3617. *note Classification of Characters::).
  3618. • Certain options require an argument. For example, the ‘-o’ option
  3619. of the ‘ld’ command requires an argument—an output file name.
  3620. • An option and its argument may or may not appear as separate
  3621. tokens. (In other words, the whitespace separating them is
  3622. optional.) Thus, ‘-o foo’ and ‘-ofoo’ are equivalent.
  3623. • Options typically precede other non-option arguments.
  3624. The implementations of ‘getopt’ and ‘argp_parse’ in the GNU C
  3625. Library normally make it appear as if all the option arguments were
  3626. specified before all the non-option arguments for the purposes of
  3627. parsing, even if the user of your program intermixed option and
  3628. non-option arguments. They do this by reordering the elements of
  3629. the ARGV array. This behavior is nonstandard; if you want to
  3630. suppress it, define the ‘_POSIX_OPTION_ORDER’ environment variable.
  3631. *Note Standard Environment::.
  3632. • The argument ‘--’ terminates all options; any following arguments
  3633. are treated as non-option arguments, even if they begin with a
  3634. hyphen.
  3635. • A token consisting of a single hyphen character is interpreted as
  3636. an ordinary non-option argument. By convention, it is used to
  3637. specify input from or output to the standard input and output
  3638. streams.
  3639. • Options may be supplied in any order, or appear multiple times.
  3640. The interpretation is left up to the particular application
  3641. program.
  3642. GNU adds “long options” to these conventions. Long options consist
  3643. of ‘--’ followed by a name made of alphanumeric characters and dashes.
  3644. Option names are typically one to three words long, with hyphens to
  3645. separate words. Users can abbreviate the option names as long as the
  3646. abbreviations are unique.
  3647. To specify an argument for a long option, write ‘--NAME=VALUE’. This
  3648. syntax enables a long option to accept an argument that is itself
  3649. optional.
  3650. Eventually, GNU systems will provide completion for long option names
  3651. in the shell.
  3652. 
  3653. File: libc.info, Node: Parsing Program Arguments, Prev: Argument Syntax, Up: Program Arguments
  3654. 25.1.2 Parsing Program Arguments
  3655. --------------------------------
  3656. If the syntax for the command line arguments to your program is simple
  3657. enough, you can simply pick the arguments off from ARGV by hand. But
  3658. unless your program takes a fixed number of arguments, or all of the
  3659. arguments are interpreted in the same way (as file names, for example),
  3660. you are usually better off using ‘getopt’ (*note Getopt::) or
  3661. ‘argp_parse’ (*note Argp::) to do the parsing.
  3662. ‘getopt’ is more standard (the short-option only version of it is a
  3663. part of the POSIX standard), but using ‘argp_parse’ is often easier,
  3664. both for very simple and very complex option structures, because it does
  3665. more of the dirty work for you.
  3666. * Menu:
  3667. * Getopt:: Parsing program options using ‘getopt’.
  3668. * Argp:: Parsing program options using ‘argp_parse’.
  3669. * Suboptions:: Some programs need more detailed options.
  3670. * Suboptions Example:: This shows how it could be done for ‘mount’.
  3671. 
  3672. File: libc.info, Node: Getopt, Next: Argp, Up: Parsing Program Arguments
  3673. 25.2 Parsing program options using ‘getopt’
  3674. ===========================================
  3675. The ‘getopt’ and ‘getopt_long’ functions automate some of the chore
  3676. involved in parsing typical unix command line options.
  3677. * Menu:
  3678. * Using Getopt:: Using the ‘getopt’ function.
  3679. * Example of Getopt:: An example of parsing options with ‘getopt’.
  3680. * Getopt Long Options:: GNU suggests utilities accept long-named
  3681. options; here is one way to do.
  3682. * Getopt Long Option Example:: An example of using ‘getopt_long’.
  3683. 
  3684. File: libc.info, Node: Using Getopt, Next: Example of Getopt, Up: Getopt
  3685. 25.2.1 Using the ‘getopt’ function
  3686. ----------------------------------
  3687. Here are the details about how to call the ‘getopt’ function. To use
  3688. this facility, your program must include the header file ‘unistd.h’.
  3689. -- Variable: int opterr
  3690. If the value of this variable is nonzero, then ‘getopt’ prints an
  3691. error message to the standard error stream if it encounters an
  3692. unknown option character or an option with a missing required
  3693. argument. This is the default behavior. If you set this variable
  3694. to zero, ‘getopt’ does not print any messages, but it still returns
  3695. the character ‘?’ to indicate an error.
  3696. -- Variable: int optopt
  3697. When ‘getopt’ encounters an unknown option character or an option
  3698. with a missing required argument, it stores that option character
  3699. in this variable. You can use this for providing your own
  3700. diagnostic messages.
  3701. -- Variable: int optind
  3702. This variable is set by ‘getopt’ to the index of the next element
  3703. of the ARGV array to be processed. Once ‘getopt’ has found all of
  3704. the option arguments, you can use this variable to determine where
  3705. the remaining non-option arguments begin. The initial value of
  3706. this variable is ‘1’.
  3707. -- Variable: char * optarg
  3708. This variable is set by ‘getopt’ to point at the value of the
  3709. option argument, for those options that accept arguments.
  3710. -- Function: int getopt (int ARGC, char *const *ARGV, const char
  3711. *OPTIONS)
  3712. Preliminary: | MT-Unsafe race:getopt env | AS-Unsafe heap i18n lock
  3713. corrupt | AC-Unsafe mem lock corrupt | *Note POSIX Safety
  3714. Concepts::.
  3715. The ‘getopt’ function gets the next option argument from the
  3716. argument list specified by the ARGV and ARGC arguments. Normally
  3717. these values come directly from the arguments received by ‘main’.
  3718. The OPTIONS argument is a string that specifies the option
  3719. characters that are valid for this program. An option character in
  3720. this string can be followed by a colon (‘:’) to indicate that it
  3721. takes a required argument. If an option character is followed by
  3722. two colons (‘::’), its argument is optional; this is a GNU
  3723. extension.
  3724. ‘getopt’ has three ways to deal with options that follow
  3725. non-options ARGV elements. The special argument ‘--’ forces in all
  3726. cases the end of option scanning.
  3727. • The default is to permute the contents of ARGV while scanning
  3728. it so that eventually all the non-options are at the end.
  3729. This allows options to be given in any order, even with
  3730. programs that were not written to expect this.
  3731. • If the OPTIONS argument string begins with a hyphen (‘-’),
  3732. this is treated specially. It permits arguments that are not
  3733. options to be returned as if they were associated with option
  3734. character ‘\1’.
  3735. • POSIX demands the following behavior: the first non-option
  3736. stops option processing. This mode is selected by either
  3737. setting the environment variable ‘POSIXLY_CORRECT’ or
  3738. beginning the OPTIONS argument string with a plus sign (‘+’).
  3739. The ‘getopt’ function returns the option character for the next
  3740. command line option. When no more option arguments are available,
  3741. it returns ‘-1’. There may still be more non-option arguments; you
  3742. must compare the external variable ‘optind’ against the ARGC
  3743. parameter to check this.
  3744. If the option has an argument, ‘getopt’ returns the argument by
  3745. storing it in the variable OPTARG. You don’t ordinarily need to
  3746. copy the ‘optarg’ string, since it is a pointer into the original
  3747. ARGV array, not into a static area that might be overwritten.
  3748. If ‘getopt’ finds an option character in ARGV that was not included
  3749. in OPTIONS, or a missing option argument, it returns ‘?’ and sets
  3750. the external variable ‘optopt’ to the actual option character. If
  3751. the first character of OPTIONS is a colon (‘:’), then ‘getopt’
  3752. returns ‘:’ instead of ‘?’ to indicate a missing option argument.
  3753. In addition, if the external variable ‘opterr’ is nonzero (which is
  3754. the default), ‘getopt’ prints an error message.
  3755. 
  3756. File: libc.info, Node: Example of Getopt, Next: Getopt Long Options, Prev: Using Getopt, Up: Getopt
  3757. 25.2.2 Example of Parsing Arguments with ‘getopt’
  3758. -------------------------------------------------
  3759. Here is an example showing how ‘getopt’ is typically used. The key
  3760. points to notice are:
  3761. • Normally, ‘getopt’ is called in a loop. When ‘getopt’ returns
  3762. ‘-1’, indicating no more options are present, the loop terminates.
  3763. • A ‘switch’ statement is used to dispatch on the return value from
  3764. ‘getopt’. In typical use, each case just sets a variable that is
  3765. used later in the program.
  3766. • A second loop is used to process the remaining non-option
  3767. arguments.
  3768. #include <ctype.h>
  3769. #include <stdio.h>
  3770. #include <stdlib.h>
  3771. #include <unistd.h>
  3772. int
  3773. main (int argc, char **argv)
  3774. {
  3775. int aflag = 0;
  3776. int bflag = 0;
  3777. char *cvalue = NULL;
  3778. int index;
  3779. int c;
  3780. opterr = 0;
  3781. while ((c = getopt (argc, argv, "abc:")) != -1)
  3782. switch (c)
  3783. {
  3784. case 'a':
  3785. aflag = 1;
  3786. break;
  3787. case 'b':
  3788. bflag = 1;
  3789. break;
  3790. case 'c':
  3791. cvalue = optarg;
  3792. break;
  3793. case '?':
  3794. if (optopt == 'c')
  3795. fprintf (stderr, "Option -%c requires an argument.\n", optopt);
  3796. else if (isprint (optopt))
  3797. fprintf (stderr, "Unknown option `-%c'.\n", optopt);
  3798. else
  3799. fprintf (stderr,
  3800. "Unknown option character `\\x%x'.\n",
  3801. optopt);
  3802. return 1;
  3803. default:
  3804. abort ();
  3805. }
  3806. printf ("aflag = %d, bflag = %d, cvalue = %s\n",
  3807. aflag, bflag, cvalue);
  3808. for (index = optind; index < argc; index++)
  3809. printf ("Non-option argument %s\n", argv[index]);
  3810. return 0;
  3811. }
  3812. Here are some examples showing what this program prints with
  3813. different combinations of arguments:
  3814. % testopt
  3815. aflag = 0, bflag = 0, cvalue = (null)
  3816. % testopt -a -b
  3817. aflag = 1, bflag = 1, cvalue = (null)
  3818. % testopt -ab
  3819. aflag = 1, bflag = 1, cvalue = (null)
  3820. % testopt -c foo
  3821. aflag = 0, bflag = 0, cvalue = foo
  3822. % testopt -cfoo
  3823. aflag = 0, bflag = 0, cvalue = foo
  3824. % testopt arg1
  3825. aflag = 0, bflag = 0, cvalue = (null)
  3826. Non-option argument arg1
  3827. % testopt -a arg1
  3828. aflag = 1, bflag = 0, cvalue = (null)
  3829. Non-option argument arg1
  3830. % testopt -c foo arg1
  3831. aflag = 0, bflag = 0, cvalue = foo
  3832. Non-option argument arg1
  3833. % testopt -a -- -b
  3834. aflag = 1, bflag = 0, cvalue = (null)
  3835. Non-option argument -b
  3836. % testopt -a -
  3837. aflag = 1, bflag = 0, cvalue = (null)
  3838. Non-option argument -
  3839. 
  3840. File: libc.info, Node: Getopt Long Options, Next: Getopt Long Option Example, Prev: Example of Getopt, Up: Getopt
  3841. 25.2.3 Parsing Long Options with ‘getopt_long’
  3842. ----------------------------------------------
  3843. To accept GNU-style long options as well as single-character options,
  3844. use ‘getopt_long’ instead of ‘getopt’. This function is declared in
  3845. ‘getopt.h’, not ‘unistd.h’. You should make every program accept long
  3846. options if it uses any options, for this takes little extra work and
  3847. helps beginners remember how to use the program.
  3848. -- Data Type: struct option
  3849. This structure describes a single long option name for the sake of
  3850. ‘getopt_long’. The argument LONGOPTS must be an array of these
  3851. structures, one for each long option. Terminate the array with an
  3852. element containing all zeros.
  3853. The ‘struct option’ structure has these fields:
  3854. ‘const char *name’
  3855. This field is the name of the option. It is a string.
  3856. ‘int has_arg’
  3857. This field says whether the option takes an argument. It is
  3858. an integer, and there are three legitimate values:
  3859. ‘no_argument’, ‘required_argument’ and ‘optional_argument’.
  3860. ‘int *flag’
  3861. ‘int val’
  3862. These fields control how to report or act on the option when
  3863. it occurs.
  3864. If ‘flag’ is a null pointer, then the ‘val’ is a value which
  3865. identifies this option. Often these values are chosen to
  3866. uniquely identify particular long options.
  3867. If ‘flag’ is not a null pointer, it should be the address of
  3868. an ‘int’ variable which is the flag for this option. The
  3869. value in ‘val’ is the value to store in the flag to indicate
  3870. that the option was seen.
  3871. -- Function: int getopt_long (int ARGC, char *const *ARGV, const char
  3872. *SHORTOPTS, const struct option *LONGOPTS, int *INDEXPTR)
  3873. Preliminary: | MT-Unsafe race:getopt env | AS-Unsafe heap i18n lock
  3874. corrupt | AC-Unsafe mem lock corrupt | *Note POSIX Safety
  3875. Concepts::.
  3876. Decode options from the vector ARGV (whose length is ARGC). The
  3877. argument SHORTOPTS describes the short options to accept, just as
  3878. it does in ‘getopt’. The argument LONGOPTS describes the long
  3879. options to accept (see above).
  3880. When ‘getopt_long’ encounters a short option, it does the same
  3881. thing that ‘getopt’ would do: it returns the character code for the
  3882. option, and stores the option’s argument (if it has one) in
  3883. ‘optarg’.
  3884. When ‘getopt_long’ encounters a long option, it takes actions based
  3885. on the ‘flag’ and ‘val’ fields of the definition of that option.
  3886. If ‘flag’ is a null pointer, then ‘getopt_long’ returns the
  3887. contents of ‘val’ to indicate which option it found. You should
  3888. arrange distinct values in the ‘val’ field for options with
  3889. different meanings, so you can decode these values after
  3890. ‘getopt_long’ returns. If the long option is equivalent to a short
  3891. option, you can use the short option’s character code in ‘val’.
  3892. If ‘flag’ is not a null pointer, that means this option should just
  3893. set a flag in the program. The flag is a variable of type ‘int’
  3894. that you define. Put the address of the flag in the ‘flag’ field.
  3895. Put in the ‘val’ field the value you would like this option to
  3896. store in the flag. In this case, ‘getopt_long’ returns ‘0’.
  3897. For any long option, ‘getopt_long’ tells you the index in the array
  3898. LONGOPTS of the options definition, by storing it into ‘*INDEXPTR’.
  3899. You can get the name of the option with ‘LONGOPTS[*INDEXPTR].name’.
  3900. So you can distinguish among long options either by the values in
  3901. their ‘val’ fields or by their indices. You can also distinguish
  3902. in this way among long options that set flags.
  3903. When a long option has an argument, ‘getopt_long’ puts the argument
  3904. value in the variable ‘optarg’ before returning. When the option
  3905. has no argument, the value in ‘optarg’ is a null pointer. This is
  3906. how you can tell whether an optional argument was supplied.
  3907. When ‘getopt_long’ has no more options to handle, it returns ‘-1’,
  3908. and leaves in the variable ‘optind’ the index in ARGV of the next
  3909. remaining argument.
  3910. Since long option names were used before ‘getopt_long’ was invented
  3911. there are program interfaces which require programs to recognize options
  3912. like ‘-option value’ instead of ‘--option value’. To enable these
  3913. programs to use the GNU getopt functionality there is one more function
  3914. available.
  3915. -- Function: int getopt_long_only (int ARGC, char *const *ARGV, const
  3916. char *SHORTOPTS, const struct option *LONGOPTS, int *INDEXPTR)
  3917. Preliminary: | MT-Unsafe race:getopt env | AS-Unsafe heap i18n lock
  3918. corrupt | AC-Unsafe mem lock corrupt | *Note POSIX Safety
  3919. Concepts::.
  3920. The ‘getopt_long_only’ function is equivalent to the ‘getopt_long’
  3921. function but it allows the user of the application to pass long
  3922. options with only ‘-’ instead of ‘--’. The ‘--’ prefix is still
  3923. recognized but instead of looking through the short options if a
  3924. ‘-’ is seen it is first tried whether this parameter names a long
  3925. option. If not, it is parsed as a short option.
  3926. Assuming ‘getopt_long_only’ is used starting an application with
  3927. app -foo
  3928. the ‘getopt_long_only’ will first look for a long option named
  3929. ‘foo’. If this is not found, the short options ‘f’, ‘o’, and again
  3930. ‘o’ are recognized.
  3931. 
  3932. File: libc.info, Node: Getopt Long Option Example, Prev: Getopt Long Options, Up: Getopt
  3933. 25.2.4 Example of Parsing Long Options with ‘getopt_long’
  3934. ---------------------------------------------------------
  3935. #include <stdio.h>
  3936. #include <stdlib.h>
  3937. #include <getopt.h>
  3938. /* Flag set by ‘--verbose’. */
  3939. static int verbose_flag;
  3940. int
  3941. main (int argc, char **argv)
  3942. {
  3943. int c;
  3944. while (1)
  3945. {
  3946. static struct option long_options[] =
  3947. {
  3948. /* These options set a flag. */
  3949. {"verbose", no_argument, &verbose_flag, 1},
  3950. {"brief", no_argument, &verbose_flag, 0},
  3951. /* These options don’t set a flag.
  3952. We distinguish them by their indices. */
  3953. {"add", no_argument, 0, 'a'},
  3954. {"append", no_argument, 0, 'b'},
  3955. {"delete", required_argument, 0, 'd'},
  3956. {"create", required_argument, 0, 'c'},
  3957. {"file", required_argument, 0, 'f'},
  3958. {0, 0, 0, 0}
  3959. };
  3960. /* ‘getopt_long’ stores the option index here. */
  3961. int option_index = 0;
  3962. c = getopt_long (argc, argv, "abc:d:f:",
  3963. long_options, &option_index);
  3964. /* Detect the end of the options. */
  3965. if (c == -1)
  3966. break;
  3967. switch (c)
  3968. {
  3969. case 0:
  3970. /* If this option set a flag, do nothing else now. */
  3971. if (long_options[option_index].flag != 0)
  3972. break;
  3973. printf ("option %s", long_options[option_index].name);
  3974. if (optarg)
  3975. printf (" with arg %s", optarg);
  3976. printf ("\n");
  3977. break;
  3978. case 'a':
  3979. puts ("option -a\n");
  3980. break;
  3981. case 'b':
  3982. puts ("option -b\n");
  3983. break;
  3984. case 'c':
  3985. printf ("option -c with value `%s'\n", optarg);
  3986. break;
  3987. case 'd':
  3988. printf ("option -d with value `%s'\n", optarg);
  3989. break;
  3990. case 'f':
  3991. printf ("option -f with value `%s'\n", optarg);
  3992. break;
  3993. case '?':
  3994. /* ‘getopt_long’ already printed an error message. */
  3995. break;
  3996. default:
  3997. abort ();
  3998. }
  3999. }
  4000. /* Instead of reporting ‘--verbose’
  4001. and ‘--brief’ as they are encountered,
  4002. we report the final status resulting from them. */
  4003. if (verbose_flag)
  4004. puts ("verbose flag is set");
  4005. /* Print any remaining command line arguments (not options). */
  4006. if (optind < argc)
  4007. {
  4008. printf ("non-option ARGV-elements: ");
  4009. while (optind < argc)
  4010. printf ("%s ", argv[optind++]);
  4011. putchar ('\n');
  4012. }
  4013. exit (0);
  4014. }
  4015. 
  4016. File: libc.info, Node: Argp, Next: Suboptions, Prev: Getopt, Up: Parsing Program Arguments
  4017. 25.3 Parsing Program Options with Argp
  4018. ======================================
  4019. “Argp” is an interface for parsing unix-style argument vectors. *Note
  4020. Program Arguments::.
  4021. Argp provides features unavailable in the more commonly used ‘getopt’
  4022. interface. These features include automatically producing output in
  4023. response to the ‘--help’ and ‘--version’ options, as described in the
  4024. GNU coding standards. Using argp makes it less likely that programmers
  4025. will neglect to implement these additional options or keep them up to
  4026. date.
  4027. Argp also provides the ability to merge several independently defined
  4028. option parsers into one, mediating conflicts between them and making the
  4029. result appear seamless. A library can export an argp option parser that
  4030. user programs might employ in conjunction with their own option parsers,
  4031. resulting in less work for the user programs. Some programs may use
  4032. only argument parsers exported by libraries, thereby achieving
  4033. consistent and efficient option-parsing for abstractions implemented by
  4034. the libraries.
  4035. The header file ‘<argp.h>’ should be included to use argp.
  4036. * Menu:
  4037. * Argp Global Variables::
  4038. * Argp Parsers::
  4039. * Argp Option Vectors::
  4040. * Argp Parser Functions::
  4041. * Argp Children::
  4042. * Argp Flags::
  4043. * Argp Help Filtering::
  4044. * Argp Help::
  4045. * Argp Help Flags::
  4046. * Argp Examples::
  4047. * Argp User Customization::
  4048. * Suboptions Example::
  4049. 25.3.1 The ‘argp_parse’ Function
  4050. --------------------------------
  4051. The main interface to argp is the ‘argp_parse’ function. In many cases,
  4052. calling ‘argp_parse’ is the only argument-parsing code needed in ‘main’.
  4053. *Note Program Arguments::.
  4054. -- Function: error_t argp_parse (const struct argp *ARGP, int ARGC,
  4055. char **ARGV, unsigned FLAGS, int *ARG_INDEX, void *INPUT)
  4056. Preliminary: | MT-Unsafe race:argpbuf locale env | AS-Unsafe heap
  4057. i18n lock corrupt | AC-Unsafe mem lock corrupt | *Note POSIX Safety
  4058. Concepts::.
  4059. The ‘argp_parse’ function parses the arguments in ARGV, of length
  4060. ARGC, using the argp parser ARGP. *Note Argp Parsers::. Passing a
  4061. null pointer for ARGP is the same as using a ‘struct argp’
  4062. containing all zeros.
  4063. FLAGS is a set of flag bits that modify the parsing behavior.
  4064. *Note Argp Flags::. INPUT is passed through to the argp parser
  4065. ARGP, and has meaning defined by ARGP. A typical usage is to pass
  4066. a pointer to a structure which is used for specifying parameters to
  4067. the parser and passing back the results.
  4068. Unless the ‘ARGP_NO_EXIT’ or ‘ARGP_NO_HELP’ flags are included in
  4069. FLAGS, calling ‘argp_parse’ may result in the program exiting.
  4070. This behavior is true if an error is detected, or when an unknown
  4071. option is encountered. *Note Program Termination::.
  4072. If ARG_INDEX is non-null, the index of the first unparsed option in
  4073. ARGV is returned as a value.
  4074. The return value is zero for successful parsing, or an error code
  4075. (*note Error Codes::) if an error is detected. Different argp
  4076. parsers may return arbitrary error codes, but the standard error
  4077. codes are: ‘ENOMEM’ if a memory allocation error occurred, or
  4078. ‘EINVAL’ if an unknown option or option argument is encountered.
  4079. * Menu:
  4080. * Globals: Argp Global Variables. Global argp parameters.
  4081. * Parsers: Argp Parsers. Defining parsers for use with ‘argp_parse’.
  4082. * Flags: Argp Flags. Flags that modify the behavior of ‘argp_parse’.
  4083. * Help: Argp Help. Printing help messages when not parsing.
  4084. * Examples: Argp Examples. Simple examples of programs using argp.
  4085. * Customization: Argp User Customization.
  4086. Users may control the ‘--help’ output format.
  4087. 
  4088. File: libc.info, Node: Argp Global Variables, Next: Argp Parsers, Up: Argp
  4089. 25.3.2 Argp Global Variables
  4090. ----------------------------
  4091. These variables make it easy for user programs to implement the
  4092. ‘--version’ option and provide a bug-reporting address in the ‘--help’
  4093. output. These are implemented in argp by default.
  4094. -- Variable: const char * argp_program_version
  4095. If defined or set by the user program to a non-zero value, then a
  4096. ‘--version’ option is added when parsing with ‘argp_parse’, which
  4097. will print the ‘--version’ string followed by a newline and exit.
  4098. The exception to this is if the ‘ARGP_NO_EXIT’ flag is used.
  4099. -- Variable: const char * argp_program_bug_address
  4100. If defined or set by the user program to a non-zero value,
  4101. ‘argp_program_bug_address’ should point to a string that will be
  4102. printed at the end of the standard output for the ‘--help’ option,
  4103. embedded in a sentence that says ‘Report bugs to ADDRESS.’.
  4104. -- Variable: argp_program_version_hook
  4105. If defined or set by the user program to a non-zero value, a
  4106. ‘--version’ option is added when parsing with ‘arg_parse’, which
  4107. prints the program version and exits with a status of zero. This
  4108. is not the case if the ‘ARGP_NO_HELP’ flag is used. If the
  4109. ‘ARGP_NO_EXIT’ flag is set, the exit behavior of the program is
  4110. suppressed or modified, as when the argp parser is going to be used
  4111. by other programs.
  4112. It should point to a function with this type of signature:
  4113. void PRINT-VERSION (FILE *STREAM, struct argp_state *STATE)
  4114. *Note Argp Parsing State::, for an explanation of STATE.
  4115. This variable takes precedence over ‘argp_program_version’, and is
  4116. useful if a program has version information not easily expressed in
  4117. a simple string.
  4118. -- Variable: error_t argp_err_exit_status
  4119. This is the exit status used when argp exits due to a parsing
  4120. error. If not defined or set by the user program, this defaults
  4121. to: ‘EX_USAGE’ from ‘<sysexits.h>’.
  4122. 
  4123. File: libc.info, Node: Argp Parsers, Next: Argp Flags, Prev: Argp Global Variables, Up: Argp
  4124. 25.3.3 Specifying Argp Parsers
  4125. ------------------------------
  4126. The first argument to the ‘argp_parse’ function is a pointer to a
  4127. ‘struct argp’, which is known as an “argp parser”:
  4128. -- Data Type: struct argp
  4129. This structure specifies how to parse a given set of options and
  4130. arguments, perhaps in conjunction with other argp parsers. It has
  4131. the following fields:
  4132. ‘const struct argp_option *options’
  4133. A pointer to a vector of ‘argp_option’ structures specifying
  4134. which options this argp parser understands; it may be zero if
  4135. there are no options at all. *Note Argp Option Vectors::.
  4136. ‘argp_parser_t parser’
  4137. A pointer to a function that defines actions for this parser;
  4138. it is called for each option parsed, and at other well-defined
  4139. points in the parsing process. A value of zero is the same as
  4140. a pointer to a function that always returns
  4141. ‘ARGP_ERR_UNKNOWN’. *Note Argp Parser Functions::.
  4142. ‘const char *args_doc’
  4143. If non-zero, a string describing what non-option arguments are
  4144. called by this parser. This is only used to print the
  4145. ‘Usage:’ message. If it contains newlines, the strings
  4146. separated by them are considered alternative usage patterns
  4147. and printed on separate lines. Lines after the first are
  4148. prefixed by ‘ or: ’ instead of ‘Usage:’.
  4149. ‘const char *doc’
  4150. If non-zero, a string containing extra text to be printed
  4151. before and after the options in a long help message, with the
  4152. two sections separated by a vertical tab (‘'\v'’, ‘'\013'’)
  4153. character. By convention, the documentation before the
  4154. options is just a short string explaining what the program
  4155. does. Documentation printed after the options describe
  4156. behavior in more detail.
  4157. ‘const struct argp_child *children’
  4158. A pointer to a vector of ‘argp_child’ structures. This
  4159. pointer specifies which additional argp parsers should be
  4160. combined with this one. *Note Argp Children::.
  4161. ‘char *(*help_filter)(int KEY, const char *TEXT, void *INPUT)’
  4162. If non-zero, a pointer to a function that filters the output
  4163. of help messages. *Note Argp Help Filtering::.
  4164. ‘const char *argp_domain’
  4165. If non-zero, the strings used in the argp library are
  4166. translated using the domain described by this string. If
  4167. zero, the current default domain is used.
  4168. Of the above group, ‘options’, ‘parser’, ‘args_doc’, and the ‘doc’
  4169. fields are usually all that are needed. If an argp parser is defined as
  4170. an initialized C variable, only the fields used need be specified in the
  4171. initializer. The rest will default to zero due to the way C structure
  4172. initialization works. This design is exploited in most argp structures;
  4173. the most-used fields are grouped near the beginning, the unused fields
  4174. left unspecified.
  4175. * Menu:
  4176. * Options: Argp Option Vectors. Specifying options in an argp parser.
  4177. * Argp Parser Functions:: Defining actions for an argp parser.
  4178. * Children: Argp Children. Combining multiple argp parsers.
  4179. * Help Filtering: Argp Help Filtering. Customizing help output for an argp parser.
  4180. 
  4181. File: libc.info, Node: Argp Option Vectors, Next: Argp Parser Functions, Prev: Argp Parsers, Up: Argp Parsers
  4182. 25.3.4 Specifying Options in an Argp Parser
  4183. -------------------------------------------
  4184. The ‘options’ field in a ‘struct argp’ points to a vector of ‘struct
  4185. argp_option’ structures, each of which specifies an option that the argp
  4186. parser supports. Multiple entries may be used for a single option
  4187. provided it has multiple names. This should be terminated by an entry
  4188. with zero in all fields. Note that when using an initialized C array
  4189. for options, writing ‘{ 0 }’ is enough to achieve this.
  4190. -- Data Type: struct argp_option
  4191. This structure specifies a single option that an argp parser
  4192. understands, as well as how to parse and document that option. It
  4193. has the following fields:
  4194. ‘const char *name’
  4195. The long name for this option, corresponding to the long
  4196. option ‘--NAME’; this field may be zero if this option _only_
  4197. has a short name. To specify multiple names for an option,
  4198. additional entries may follow this one, with the
  4199. ‘OPTION_ALIAS’ flag set. *Note Argp Option Flags::.
  4200. ‘int key’
  4201. The integer key provided by the current option to the option
  4202. parser. If KEY has a value that is a printable ASCII
  4203. character (i.e., ‘isascii (KEY)’ is true), it _also_ specifies
  4204. a short option ‘-CHAR’, where CHAR is the ASCII character with
  4205. the code KEY.
  4206. ‘const char *arg’
  4207. If non-zero, this is the name of an argument associated with
  4208. this option, which must be provided (e.g., with the
  4209. ‘--NAME=VALUE’ or ‘-CHAR VALUE’ syntaxes), unless the
  4210. ‘OPTION_ARG_OPTIONAL’ flag (*note Argp Option Flags::) is set,
  4211. in which case it _may_ be provided.
  4212. ‘int flags’
  4213. Flags associated with this option, some of which are referred
  4214. to above. *Note Argp Option Flags::.
  4215. ‘const char *doc’
  4216. A documentation string for this option, for printing in help
  4217. messages.
  4218. If both the ‘name’ and ‘key’ fields are zero, this string will
  4219. be printed tabbed left from the normal option column, making
  4220. it useful as a group header. This will be the first thing
  4221. printed in its group. In this usage, it’s conventional to end
  4222. the string with a ‘:’ character.
  4223. ‘int group’
  4224. Group identity for this option.
  4225. In a long help message, options are sorted alphabetically
  4226. within each group, and the groups presented in the order 0, 1,
  4227. 2, ..., N, −M, ..., −2, −1.
  4228. Every entry in an options array with this field 0 will inherit
  4229. the group number of the previous entry, or zero if it’s the
  4230. first one. If it’s a group header with ‘name’ and ‘key’
  4231. fields both zero, the previous entry + 1 is the default.
  4232. Automagic options such as ‘--help’ are put into group −1.
  4233. Note that because of C structure initialization rules, this
  4234. field often need not be specified, because 0 is the correct
  4235. value.
  4236. * Menu:
  4237. * Flags: Argp Option Flags. Flags for options.
  4238. 
  4239. File: libc.info, Node: Argp Option Flags, Up: Argp Option Vectors
  4240. 25.3.4.1 Flags for Argp Options
  4241. ...............................
  4242. The following flags may be or’d together in the ‘flags’ field of a
  4243. ‘struct argp_option’. These flags control various aspects of how that
  4244. option is parsed or displayed in help messages:
  4245. ‘OPTION_ARG_OPTIONAL’
  4246. The argument associated with this option is optional.
  4247. ‘OPTION_HIDDEN’
  4248. This option isn’t displayed in any help messages.
  4249. ‘OPTION_ALIAS’
  4250. This option is an alias for the closest previous non-alias option.
  4251. This means that it will be displayed in the same help entry, and
  4252. will inherit fields other than ‘name’ and ‘key’ from the option
  4253. being aliased.
  4254. ‘OPTION_DOC’
  4255. This option isn’t actually an option and should be ignored by the
  4256. actual option parser. It is an arbitrary section of documentation
  4257. that should be displayed in much the same manner as the options.
  4258. This is known as a “documentation option”.
  4259. If this flag is set, then the option ‘name’ field is displayed
  4260. unmodified (e.g., no ‘--’ prefix is added) at the left-margin where
  4261. a _short_ option would normally be displayed, and this
  4262. documentation string is left in its usual place. For purposes of
  4263. sorting, any leading whitespace and punctuation is ignored, unless
  4264. the first non-whitespace character is ‘-’. This entry is displayed
  4265. after all options, after ‘OPTION_DOC’ entries with a leading ‘-’,
  4266. in the same group.
  4267. ‘OPTION_NO_USAGE’
  4268. This option shouldn’t be included in ‘long’ usage messages, but
  4269. should still be included in other help messages. This is intended
  4270. for options that are completely documented in an argp’s ‘args_doc’
  4271. field. *Note Argp Parsers::. Including this option in the generic
  4272. usage list would be redundant, and should be avoided.
  4273. For instance, if ‘args_doc’ is ‘"FOO BAR\n-x BLAH"’, and the ‘-x’
  4274. option’s purpose is to distinguish these two cases, ‘-x’ should
  4275. probably be marked ‘OPTION_NO_USAGE’.
  4276. 
  4277. File: libc.info, Node: Argp Parser Functions, Next: Argp Children, Prev: Argp Option Vectors, Up: Argp Parsers
  4278. 25.3.5 Argp Parser Functions
  4279. ----------------------------
  4280. The function pointed to by the ‘parser’ field in a ‘struct argp’ (*note
  4281. Argp Parsers::) defines what actions take place in response to each
  4282. option or argument parsed. It is also used as a hook, allowing a parser
  4283. to perform tasks at certain other points during parsing.
  4284. Argp parser functions have the following type signature:
  4285. error_t PARSER (int KEY, char *ARG, struct argp_state *STATE)
  4286. where the arguments are as follows:
  4287. KEY
  4288. For each option that is parsed, PARSER is called with a value of
  4289. KEY from that option’s ‘key’ field in the option vector. *Note
  4290. Argp Option Vectors::. PARSER is also called at other times with
  4291. special reserved keys, such as ‘ARGP_KEY_ARG’ for non-option
  4292. arguments. *Note Argp Special Keys::.
  4293. ARG
  4294. If KEY is an option, ARG is its given value. This defaults to zero
  4295. if no value is specified. Only options that have a non-zero ‘arg’
  4296. field can ever have a value. These must _always_ have a value
  4297. unless the ‘OPTION_ARG_OPTIONAL’ flag is specified. If the input
  4298. being parsed specifies a value for an option that doesn’t allow
  4299. one, an error results before PARSER ever gets called.
  4300. If KEY is ‘ARGP_KEY_ARG’, ARG is a non-option argument. Other
  4301. special keys always have a zero ARG.
  4302. STATE
  4303. STATE points to a ‘struct argp_state’, containing useful
  4304. information about the current parsing state for use by PARSER.
  4305. *Note Argp Parsing State::.
  4306. When PARSER is called, it should perform whatever action is
  4307. appropriate for KEY, and return ‘0’ for success, ‘ARGP_ERR_UNKNOWN’ if
  4308. the value of KEY is not handled by this parser function, or a unix error
  4309. code if a real error occurred. *Note Error Codes::.
  4310. -- Macro: int ARGP_ERR_UNKNOWN
  4311. Argp parser functions should return ‘ARGP_ERR_UNKNOWN’ for any KEY
  4312. value they do not recognize, or for non-option arguments (‘KEY ==
  4313. ARGP_KEY_ARG’) that they are not equipped to handle.
  4314. A typical parser function uses a switch statement on KEY:
  4315. error_t
  4316. parse_opt (int key, char *arg, struct argp_state *state)
  4317. {
  4318. switch (key)
  4319. {
  4320. case OPTION_KEY:
  4321. ACTION
  4322. break;
  4323. ...
  4324. default:
  4325. return ARGP_ERR_UNKNOWN;
  4326. }
  4327. return 0;
  4328. }
  4329. * Menu:
  4330. * Keys: Argp Special Keys. Special values for the KEY argument.
  4331. * State: Argp Parsing State. What the STATE argument refers to.
  4332. * Functions: Argp Helper Functions. Functions to help during argp parsing.
  4333. 
  4334. File: libc.info, Node: Argp Special Keys, Next: Argp Parsing State, Up: Argp Parser Functions
  4335. 25.3.5.1 Special Keys for Argp Parser Functions
  4336. ...............................................
  4337. In addition to key values corresponding to user options, the KEY
  4338. argument to argp parser functions may have a number of other special
  4339. values. In the following example ARG and STATE refer to parser function
  4340. arguments. *Note Argp Parser Functions::.
  4341. ‘ARGP_KEY_ARG’
  4342. This is not an option at all, but rather a command line argument,
  4343. whose value is pointed to by ARG.
  4344. When there are multiple parser functions in play due to argp
  4345. parsers being combined, it’s impossible to know which one will
  4346. handle a specific argument. Each is called until one returns 0 or
  4347. an error other than ‘ARGP_ERR_UNKNOWN’; if an argument is not
  4348. handled, ‘argp_parse’ immediately returns success, without parsing
  4349. any more arguments.
  4350. Once a parser function returns success for this key, that fact is
  4351. recorded, and the ‘ARGP_KEY_NO_ARGS’ case won’t be used.
  4352. _However_, if while processing the argument a parser function
  4353. decrements the ‘next’ field of its STATE argument, the option won’t
  4354. be considered processed; this is to allow you to actually modify
  4355. the argument, perhaps into an option, and have it processed again.
  4356. ‘ARGP_KEY_ARGS’
  4357. If a parser function returns ‘ARGP_ERR_UNKNOWN’ for ‘ARGP_KEY_ARG’,
  4358. it is immediately called again with the key ‘ARGP_KEY_ARGS’, which
  4359. has a similar meaning, but is slightly more convenient for
  4360. consuming all remaining arguments. ARG is 0, and the tail of the
  4361. argument vector may be found at ‘STATE->argv + STATE->next’. If
  4362. success is returned for this key, and ‘STATE->next’ is unchanged,
  4363. all remaining arguments are considered to have been consumed.
  4364. Otherwise, the amount by which ‘STATE->next’ has been adjusted
  4365. indicates how many were used. Here’s an example that uses both,
  4366. for different args:
  4367. ...
  4368. case ARGP_KEY_ARG:
  4369. if (STATE->arg_num == 0)
  4370. /* First argument */
  4371. first_arg = ARG;
  4372. else
  4373. /* Let the next case parse it. */
  4374. return ARGP_KEY_UNKNOWN;
  4375. break;
  4376. case ARGP_KEY_ARGS:
  4377. remaining_args = STATE->argv + STATE->next;
  4378. num_remaining_args = STATE->argc - STATE->next;
  4379. break;
  4380. ‘ARGP_KEY_END’
  4381. This indicates that there are no more command line arguments.
  4382. Parser functions are called in a different order, children first.
  4383. This allows each parser to clean up its state for the parent.
  4384. ‘ARGP_KEY_NO_ARGS’
  4385. Because it’s common to do some special processing if there aren’t
  4386. any non-option args, parser functions are called with this key if
  4387. they didn’t successfully process any non-option arguments. This is
  4388. called just before ‘ARGP_KEY_END’, where more general validity
  4389. checks on previously parsed arguments take place.
  4390. ‘ARGP_KEY_INIT’
  4391. This is passed in before any parsing is done. Afterwards, the
  4392. values of each element of the ‘child_input’ field of STATE, if any,
  4393. are copied to each child’s state to be the initial value of the
  4394. ‘input’ when _their_ parsers are called.
  4395. ‘ARGP_KEY_SUCCESS’
  4396. Passed in when parsing has successfully been completed, even if
  4397. arguments remain.
  4398. ‘ARGP_KEY_ERROR’
  4399. Passed in if an error has occurred and parsing is terminated. In
  4400. this case a call with a key of ‘ARGP_KEY_SUCCESS’ is never made.
  4401. ‘ARGP_KEY_FINI’
  4402. The final key ever seen by any parser, even after
  4403. ‘ARGP_KEY_SUCCESS’ and ‘ARGP_KEY_ERROR’. Any resources allocated
  4404. by ‘ARGP_KEY_INIT’ may be freed here. At times, certain resources
  4405. allocated are to be returned to the caller after a successful
  4406. parse. In that case, those particular resources can be freed in
  4407. the ‘ARGP_KEY_ERROR’ case.
  4408. In all cases, ‘ARGP_KEY_INIT’ is the first key seen by parser
  4409. functions, and ‘ARGP_KEY_FINI’ the last, unless an error was returned by
  4410. the parser for ‘ARGP_KEY_INIT’. Other keys can occur in one the
  4411. following orders. OPT refers to an arbitrary option key:
  4412. OPT... ‘ARGP_KEY_NO_ARGS’ ‘ARGP_KEY_END’ ‘ARGP_KEY_SUCCESS’
  4413. The arguments being parsed did not contain any non-option
  4414. arguments.
  4415. ( OPT | ‘ARGP_KEY_ARG’ )... ‘ARGP_KEY_END’ ‘ARGP_KEY_SUCCESS’
  4416. All non-option arguments were successfully handled by a parser
  4417. function. There may be multiple parser functions if multiple argp
  4418. parsers were combined.
  4419. ( OPT | ‘ARGP_KEY_ARG’ )... ‘ARGP_KEY_SUCCESS’
  4420. Some non-option argument went unrecognized.
  4421. This occurs when every parser function returns ‘ARGP_KEY_UNKNOWN’
  4422. for an argument, in which case parsing stops at that argument if
  4423. ARG_INDEX is a null pointer. Otherwise an error occurs.
  4424. In all cases, if a non-null value for ARG_INDEX gets passed to
  4425. ‘argp_parse’, the index of the first unparsed command-line argument is
  4426. passed back in that value.
  4427. If an error occurs and is either detected by argp or because a parser
  4428. function returned an error value, each parser is called with
  4429. ‘ARGP_KEY_ERROR’. No further calls are made, except the final call with
  4430. ‘ARGP_KEY_FINI’.
  4431. 
  4432. File: libc.info, Node: Argp Parsing State, Next: Argp Helper Functions, Prev: Argp Special Keys, Up: Argp Parser Functions
  4433. 25.3.5.2 Argp Parsing State
  4434. ...........................
  4435. The third argument to argp parser functions (*note Argp Parser
  4436. Functions::) is a pointer to a ‘struct argp_state’, which contains
  4437. information about the state of the option parsing.
  4438. -- Data Type: struct argp_state
  4439. This structure has the following fields, which may be modified as
  4440. noted:
  4441. ‘const struct argp *const root_argp’
  4442. The top level argp parser being parsed. Note that this is
  4443. often _not_ the same ‘struct argp’ passed into ‘argp_parse’ by
  4444. the invoking program. *Note Argp::. It is an internal argp
  4445. parser that contains options implemented by ‘argp_parse’
  4446. itself, such as ‘--help’.
  4447. ‘int argc’
  4448. ‘char **argv’
  4449. The argument vector being parsed. This may be modified.
  4450. ‘int next’
  4451. The index in ‘argv’ of the next argument to be parsed. This
  4452. may be modified.
  4453. One way to consume all remaining arguments in the input is to
  4454. set ‘STATE->next = STATE->argc’, perhaps after recording the
  4455. value of the ‘next’ field to find the consumed arguments. The
  4456. current option can be re-parsed immediately by decrementing
  4457. this field, then modifying ‘STATE->argv[STATE->next]’ to
  4458. reflect the option that should be reexamined.
  4459. ‘unsigned flags’
  4460. The flags supplied to ‘argp_parse’. These may be modified,
  4461. although some flags may only take effect when ‘argp_parse’ is
  4462. first invoked. *Note Argp Flags::.
  4463. ‘unsigned arg_num’
  4464. While calling a parsing function with the KEY argument
  4465. ‘ARGP_KEY_ARG’, this represents the number of the current arg,
  4466. starting at 0. It is incremented after each ‘ARGP_KEY_ARG’
  4467. call returns. At all other times, this is the number of
  4468. ‘ARGP_KEY_ARG’ arguments that have been processed.
  4469. ‘int quoted’
  4470. If non-zero, the index in ‘argv’ of the first argument
  4471. following a special ‘--’ argument. This prevents anything
  4472. that follows from being interpreted as an option. It is only
  4473. set after argument parsing has proceeded past this point.
  4474. ‘void *input’
  4475. An arbitrary pointer passed in from the caller of
  4476. ‘argp_parse’, in the INPUT argument.
  4477. ‘void **child_inputs’
  4478. These are values that will be passed to child parsers. This
  4479. vector will be the same length as the number of children in
  4480. the current parser. Each child parser will be given the value
  4481. of ‘STATE->child_inputs[I]’ as _its_ ‘STATE->input’ field,
  4482. where I is the index of the child in the this parser’s
  4483. ‘children’ field. *Note Argp Children::.
  4484. ‘void *hook’
  4485. For the parser function’s use. Initialized to 0, but
  4486. otherwise ignored by argp.
  4487. ‘char *name’
  4488. The name used when printing messages. This is initialized to
  4489. ‘argv[0]’, or ‘program_invocation_name’ if ‘argv[0]’ is
  4490. unavailable.
  4491. ‘FILE *err_stream’
  4492. ‘FILE *out_stream’
  4493. The stdio streams used when argp prints. Error messages are
  4494. printed to ‘err_stream’, all other output, such as ‘--help’
  4495. output) to ‘out_stream’. These are initialized to ‘stderr’
  4496. and ‘stdout’ respectively. *Note Standard Streams::.
  4497. ‘void *pstate’
  4498. Private, for use by the argp implementation.
  4499. 
  4500. File: libc.info, Node: Argp Helper Functions, Prev: Argp Parsing State, Up: Argp Parser Functions
  4501. 25.3.5.3 Functions For Use in Argp Parsers
  4502. ..........................................
  4503. Argp provides a number of functions available to the user of argp (*note
  4504. Argp Parser Functions::), mostly for producing error messages. These
  4505. take as their first argument the STATE argument to the parser function.
  4506. *Note Argp Parsing State::.
  4507. -- Function: void argp_usage (const struct argp_state *STATE)
  4508. Preliminary: | MT-Unsafe race:argpbuf env locale | AS-Unsafe heap
  4509. i18n corrupt | AC-Unsafe mem corrupt lock | *Note POSIX Safety
  4510. Concepts::.
  4511. Outputs the standard usage message for the argp parser referred to
  4512. by STATE to ‘STATE->err_stream’ and terminates the program with
  4513. ‘exit (argp_err_exit_status)’. *Note Argp Global Variables::.
  4514. -- Function: void argp_error (const struct argp_state *STATE, const
  4515. char *FMT, ...)
  4516. Preliminary: | MT-Unsafe race:argpbuf env locale | AS-Unsafe heap
  4517. i18n corrupt | AC-Unsafe mem corrupt lock | *Note POSIX Safety
  4518. Concepts::.
  4519. Prints the printf format string FMT and following args, preceded by
  4520. the program name and ‘:’, and followed by a ‘Try ... --help’
  4521. message, and terminates the program with an exit status of
  4522. ‘argp_err_exit_status’. *Note Argp Global Variables::.
  4523. -- Function: void argp_failure (const struct argp_state *STATE, int
  4524. STATUS, int ERRNUM, const char *FMT, ...)
  4525. Preliminary: | MT-Safe | AS-Unsafe corrupt heap | AC-Unsafe lock
  4526. corrupt mem | *Note POSIX Safety Concepts::.
  4527. Similar to the standard GNU error-reporting function ‘error’, this
  4528. prints the program name and ‘:’, the printf format string FMT, and
  4529. the appropriate following args. If it is non-zero, the standard
  4530. unix error text for ERRNUM is printed. If STATUS is non-zero, it
  4531. terminates the program with that value as its exit status.
  4532. The difference between ‘argp_failure’ and ‘argp_error’ is that
  4533. ‘argp_error’ is for _parsing errors_, whereas ‘argp_failure’ is for
  4534. other problems that occur during parsing but don’t reflect a
  4535. syntactic problem with the input, such as illegal values for
  4536. options, bad phase of the moon, etc.
  4537. -- Function: void argp_state_help (const struct argp_state *STATE, FILE
  4538. *STREAM, unsigned FLAGS)
  4539. Preliminary: | MT-Unsafe race:argpbuf env locale | AS-Unsafe heap
  4540. i18n corrupt | AC-Unsafe mem corrupt lock | *Note POSIX Safety
  4541. Concepts::.
  4542. Outputs a help message for the argp parser referred to by STATE, to
  4543. STREAM. The FLAGS argument determines what sort of help message is
  4544. produced. *Note Argp Help Flags::.
  4545. Error output is sent to ‘STATE->err_stream’, and the program name
  4546. printed is ‘STATE->name’.
  4547. The output or program termination behavior of these functions may be
  4548. suppressed if the ‘ARGP_NO_EXIT’ or ‘ARGP_NO_ERRS’ flags are passed to
  4549. ‘argp_parse’. *Note Argp Flags::.
  4550. This behavior is useful if an argp parser is exported for use by
  4551. other programs (e.g., by a library), and may be used in a context where
  4552. it is not desirable to terminate the program in response to parsing
  4553. errors. In argp parsers intended for such general use, and for the case
  4554. where the program _doesn’t_ terminate, calls to any of these functions
  4555. should be followed by code that returns the appropriate error code:
  4556. if (BAD ARGUMENT SYNTAX)
  4557. {
  4558. argp_usage (STATE);
  4559. return EINVAL;
  4560. }
  4561. If a parser function will _only_ be used when ‘ARGP_NO_EXIT’ is not set,
  4562. the return may be omitted.
  4563. 
  4564. File: libc.info, Node: Argp Children, Next: Argp Help Filtering, Prev: Argp Parser Functions, Up: Argp Parsers
  4565. 25.3.6 Combining Multiple Argp Parsers
  4566. --------------------------------------
  4567. The ‘children’ field in a ‘struct argp’ enables other argp parsers to be
  4568. combined with the referencing one for the parsing of a single set of
  4569. arguments. This field should point to a vector of ‘struct argp_child’,
  4570. which is terminated by an entry having a value of zero in the ‘argp’
  4571. field.
  4572. Where conflicts between combined parsers arise, as when two specify
  4573. an option with the same name, the parser conflicts are resolved in favor
  4574. of the parent argp parser(s), or the earlier of the argp parsers in the
  4575. list of children.
  4576. -- Data Type: struct argp_child
  4577. An entry in the list of subsidiary argp parsers pointed to by the
  4578. ‘children’ field in a ‘struct argp’. The fields are as follows:
  4579. ‘const struct argp *argp’
  4580. The child argp parser, or zero to end of the list.
  4581. ‘int flags’
  4582. Flags for this child.
  4583. ‘const char *header’
  4584. If non-zero, this is an optional header to be printed within
  4585. help output before the child options. As a side-effect, a
  4586. non-zero value forces the child options to be grouped
  4587. together. To achieve this effect without actually printing a
  4588. header string, use a value of ‘""’. As with header strings
  4589. specified in an option entry, the conventional value of the
  4590. last character is ‘:’. *Note Argp Option Vectors::.
  4591. ‘int group’
  4592. This is where the child options are grouped relative to the
  4593. other ‘consolidated’ options in the parent argp parser. The
  4594. values are the same as the ‘group’ field in ‘struct
  4595. argp_option’. *Note Argp Option Vectors::. All
  4596. child-groupings follow parent options at a particular group
  4597. level. If both this field and ‘header’ are zero, then the
  4598. child’s options aren’t grouped together, they are merged with
  4599. parent options at the parent option group level.
  4600. 
  4601. File: libc.info, Node: Argp Flags, Next: Argp Help, Prev: Argp Parsers, Up: Argp
  4602. 25.3.7 Flags for ‘argp_parse’
  4603. -----------------------------
  4604. The default behavior of ‘argp_parse’ is designed to be convenient for
  4605. the most common case of parsing program command line argument. To
  4606. modify these defaults, the following flags may be or’d together in the
  4607. FLAGS argument to ‘argp_parse’:
  4608. ‘ARGP_PARSE_ARGV0’
  4609. Don’t ignore the first element of the ARGV argument to
  4610. ‘argp_parse’. Unless ‘ARGP_NO_ERRS’ is set, the first element of
  4611. the argument vector is skipped for option parsing purposes, as it
  4612. corresponds to the program name in a command line.
  4613. ‘ARGP_NO_ERRS’
  4614. Don’t print error messages for unknown options to ‘stderr’; unless
  4615. this flag is set, ‘ARGP_PARSE_ARGV0’ is ignored, as ‘argv[0]’ is
  4616. used as the program name in the error messages. This flag implies
  4617. ‘ARGP_NO_EXIT’. This is based on the assumption that silent
  4618. exiting upon errors is bad behavior.
  4619. ‘ARGP_NO_ARGS’
  4620. Don’t parse any non-option args. Normally these are parsed by
  4621. calling the parse functions with a key of ‘ARGP_KEY_ARG’, the
  4622. actual argument being the value. This flag needn’t normally be
  4623. set, as the default behavior is to stop parsing as soon as an
  4624. argument fails to be parsed. *Note Argp Parser Functions::.
  4625. ‘ARGP_IN_ORDER’
  4626. Parse options and arguments in the same order they occur on the
  4627. command line. Normally they’re rearranged so that all options come
  4628. first.
  4629. ‘ARGP_NO_HELP’
  4630. Don’t provide the standard long option ‘--help’, which ordinarily
  4631. causes usage and option help information to be output to ‘stdout’
  4632. and ‘exit (0)’.
  4633. ‘ARGP_NO_EXIT’
  4634. Don’t exit on errors, although they may still result in error
  4635. messages.
  4636. ‘ARGP_LONG_ONLY’
  4637. Use the GNU getopt ‘long-only’ rules for parsing arguments. This
  4638. allows long-options to be recognized with only a single ‘-’ (i.e.,
  4639. ‘-help’). This results in a less useful interface, and its use is
  4640. discouraged as it conflicts with the way most GNU programs work as
  4641. well as the GNU coding standards.
  4642. ‘ARGP_SILENT’
  4643. Turns off any message-printing/exiting options, specifically
  4644. ‘ARGP_NO_EXIT’, ‘ARGP_NO_ERRS’, and ‘ARGP_NO_HELP’.
  4645. 
  4646. File: libc.info, Node: Argp Help Filtering, Prev: Argp Children, Up: Argp Parsers
  4647. 25.3.8 Customizing Argp Help Output
  4648. -----------------------------------
  4649. The ‘help_filter’ field in a ‘struct argp’ is a pointer to a function
  4650. that filters the text of help messages before displaying them. They
  4651. have a function signature like:
  4652. char *HELP-FILTER (int KEY, const char *TEXT, void *INPUT)
  4653. Where KEY is either a key from an option, in which case TEXT is that
  4654. option’s help text. *Note Argp Option Vectors::. Alternately, one of
  4655. the special keys with names beginning with ‘ARGP_KEY_HELP_’ might be
  4656. used, describing which other help text TEXT will contain. *Note Argp
  4657. Help Filter Keys::.
  4658. The function should return either TEXT if it remains as-is, or a
  4659. replacement string allocated using ‘malloc’. This will be either be
  4660. freed by argp or zero, which prints nothing. The value of TEXT is
  4661. supplied _after_ any translation has been done, so if any of the
  4662. replacement text needs translation, it will be done by the filter
  4663. function. INPUT is either the input supplied to ‘argp_parse’ or it is
  4664. zero, if ‘argp_help’ was called directly by the user.
  4665. * Menu:
  4666. * Keys: Argp Help Filter Keys. Special KEY values for help filter functions.
  4667. 
  4668. File: libc.info, Node: Argp Help Filter Keys, Up: Argp Help Filtering
  4669. 25.3.8.1 Special Keys for Argp Help Filter Functions
  4670. ....................................................
  4671. The following special values may be passed to an argp help filter
  4672. function as the first argument in addition to key values for user
  4673. options. They specify which help text the TEXT argument contains:
  4674. ‘ARGP_KEY_HELP_PRE_DOC’
  4675. The help text preceding options.
  4676. ‘ARGP_KEY_HELP_POST_DOC’
  4677. The help text following options.
  4678. ‘ARGP_KEY_HELP_HEADER’
  4679. The option header string.
  4680. ‘ARGP_KEY_HELP_EXTRA’
  4681. This is used after all other documentation; TEXT is zero for this
  4682. key.
  4683. ‘ARGP_KEY_HELP_DUP_ARGS_NOTE’
  4684. The explanatory note printed when duplicate option arguments have
  4685. been suppressed.
  4686. ‘ARGP_KEY_HELP_ARGS_DOC’
  4687. The argument doc string; formally the ‘args_doc’ field from the
  4688. argp parser. *Note Argp Parsers::.
  4689. 
  4690. File: libc.info, Node: Argp Help, Next: Argp Examples, Prev: Argp Flags, Up: Argp
  4691. 25.3.9 The ‘argp_help’ Function
  4692. -------------------------------
  4693. Normally programs using argp need not be written with particular
  4694. printing argument-usage-type help messages in mind as the standard
  4695. ‘--help’ option is handled automatically by argp. Typical error cases
  4696. can be handled using ‘argp_usage’ and ‘argp_error’. *Note Argp Helper
  4697. Functions::. However, if it’s desirable to print a help message in some
  4698. context other than parsing the program options, argp offers the
  4699. ‘argp_help’ interface.
  4700. -- Function: void argp_help (const struct argp *ARGP, FILE *STREAM,
  4701. unsigned FLAGS, char *NAME)
  4702. Preliminary: | MT-Unsafe race:argpbuf env locale | AS-Unsafe heap
  4703. i18n corrupt | AC-Unsafe mem corrupt lock | *Note POSIX Safety
  4704. Concepts::.
  4705. This outputs a help message for the argp parser ARGP to STREAM.
  4706. The type of messages printed will be determined by FLAGS.
  4707. Any options such as ‘--help’ that are implemented automatically by
  4708. argp itself will _not_ be present in the help output; for this
  4709. reason it is best to use ‘argp_state_help’ if calling from within
  4710. an argp parser function. *Note Argp Helper Functions::.
  4711. * Menu:
  4712. * Flags: Argp Help Flags. Specifying what sort of help message to print.
  4713. 
  4714. File: libc.info, Node: Argp Help Flags, Up: Argp Help
  4715. 25.3.10 Flags for the ‘argp_help’ Function
  4716. ------------------------------------------
  4717. When calling ‘argp_help’ (*note Argp Help::) or ‘argp_state_help’ (*note
  4718. Argp Helper Functions::) the exact output is determined by the FLAGS
  4719. argument. This should consist of any of the following flags, or’d
  4720. together:
  4721. ‘ARGP_HELP_USAGE’
  4722. A unix ‘Usage:’ message that explicitly lists all options.
  4723. ‘ARGP_HELP_SHORT_USAGE’
  4724. A unix ‘Usage:’ message that displays an appropriate placeholder to
  4725. indicate where the options go; useful for showing the non-option
  4726. argument syntax.
  4727. ‘ARGP_HELP_SEE’
  4728. A ‘Try ... for more help’ message; ‘...’ contains the program name
  4729. and ‘--help’.
  4730. ‘ARGP_HELP_LONG’
  4731. A verbose option help message that gives each option available
  4732. along with its documentation string.
  4733. ‘ARGP_HELP_PRE_DOC’
  4734. The part of the argp parser doc string preceding the verbose option
  4735. help.
  4736. ‘ARGP_HELP_POST_DOC’
  4737. The part of the argp parser doc string that following the verbose
  4738. option help.
  4739. ‘ARGP_HELP_DOC’
  4740. ‘(ARGP_HELP_PRE_DOC | ARGP_HELP_POST_DOC)’
  4741. ‘ARGP_HELP_BUG_ADDR’
  4742. A message that prints where to report bugs for this program, if the
  4743. ‘argp_program_bug_address’ variable contains this information.
  4744. ‘ARGP_HELP_LONG_ONLY’
  4745. This will modify any output to reflect the ‘ARGP_LONG_ONLY’ mode.
  4746. The following flags are only understood when used with
  4747. ‘argp_state_help’. They control whether the function returns after
  4748. printing its output, or terminates the program:
  4749. ‘ARGP_HELP_EXIT_ERR’
  4750. This will terminate the program with ‘exit (argp_err_exit_status)’.
  4751. ‘ARGP_HELP_EXIT_OK’
  4752. This will terminate the program with ‘exit (0)’.
  4753. The following flags are combinations of the basic flags for printing
  4754. standard messages:
  4755. ‘ARGP_HELP_STD_ERR’
  4756. Assuming that an error message for a parsing error has printed,
  4757. this prints a message on how to get help, and terminates the
  4758. program with an error.
  4759. ‘ARGP_HELP_STD_USAGE’
  4760. This prints a standard usage message and terminates the program
  4761. with an error. This is used when no other specific error messages
  4762. are appropriate or available.
  4763. ‘ARGP_HELP_STD_HELP’
  4764. This prints the standard response for a ‘--help’ option, and
  4765. terminates the program successfully.
  4766. 
  4767. File: libc.info, Node: Argp Examples, Next: Argp User Customization, Prev: Argp Help, Up: Argp
  4768. 25.3.11 Argp Examples
  4769. ---------------------
  4770. These example programs demonstrate the basic usage of argp.
  4771. * Menu:
  4772. * 1: Argp Example 1. A minimal program using argp.
  4773. * 2: Argp Example 2. A program using only default options.
  4774. * 3: Argp Example 3. A simple program with user options.
  4775. * 4: Argp Example 4. Combining multiple argp parsers.
  4776. 
  4777. File: libc.info, Node: Argp Example 1, Next: Argp Example 2, Up: Argp Examples
  4778. 25.3.11.1 A Minimal Program Using Argp
  4779. ......................................
  4780. This is perhaps the smallest program possible that uses argp. It won’t
  4781. do much except give an error message and exit when there are any
  4782. arguments, and prints a rather pointless message for ‘--help’.
  4783. /* This is (probably) the smallest possible program that
  4784. uses argp. It won’t do much except give an error
  4785. messages and exit when there are any arguments, and print
  4786. a (rather pointless) messages for –help. */
  4787. #include <stdlib.h>
  4788. #include <argp.h>
  4789. int
  4790. main (int argc, char **argv)
  4791. {
  4792. argp_parse (0, argc, argv, 0, 0, 0);
  4793. exit (0);
  4794. }
  4795. 
  4796. File: libc.info, Node: Argp Example 2, Next: Argp Example 3, Prev: Argp Example 1, Up: Argp Examples
  4797. 25.3.11.2 A Program Using Argp with Only Default Options
  4798. ........................................................
  4799. This program doesn’t use any options or arguments, it uses argp to be
  4800. compliant with the GNU standard command line format.
  4801. In addition to giving no arguments and implementing a ‘--help’
  4802. option, this example has a ‘--version’ option, which will put the given
  4803. documentation string and bug address in the ‘--help’ output, as per GNU
  4804. standards.
  4805. The variable ‘argp’ contains the argument parser specification.
  4806. Adding fields to this structure is the way most parameters are passed to
  4807. ‘argp_parse’. The first three fields are normally used, but they are
  4808. not in this small program. There are also two global variables that
  4809. argp can use defined here, ‘argp_program_version’ and
  4810. ‘argp_program_bug_address’. They are considered global variables
  4811. because they will almost always be constant for a given program, even if
  4812. they use different argument parsers for various tasks.
  4813. /* This program doesn’t use any options or arguments, but uses
  4814. argp to be compliant with the GNU standard command line
  4815. format.
  4816. In addition to making sure no arguments are given, and
  4817. implementing a –help option, this example will have a
  4818. –version option, and will put the given documentation string
  4819. and bug address in the –help output, as per GNU standards.
  4820. The variable ARGP contains the argument parser specification;
  4821. adding fields to this structure is the way most parameters are
  4822. passed to argp_parse (the first three fields are usually used,
  4823. but not in this small program). There are also two global
  4824. variables that argp knows about defined here,
  4825. ARGP_PROGRAM_VERSION and ARGP_PROGRAM_BUG_ADDRESS (they are
  4826. global variables because they will almost always be constant
  4827. for a given program, even if it uses different argument
  4828. parsers for various tasks). */
  4829. #include <stdlib.h>
  4830. #include <argp.h>
  4831. const char *argp_program_version =
  4832. "argp-ex2 1.0";
  4833. const char *argp_program_bug_address =
  4834. "<bug-gnu-utils@gnu.org>";
  4835. /* Program documentation. */
  4836. static char doc[] =
  4837. "Argp example #2 -- a pretty minimal program using argp";
  4838. /* Our argument parser. The ‘options’, ‘parser’, and
  4839. ‘args_doc’ fields are zero because we have neither options or
  4840. arguments; ‘doc’ and ‘argp_program_bug_address’ will be
  4841. used in the output for ‘--help’, and the ‘--version’
  4842. option will print out ‘argp_program_version’. */
  4843. static struct argp argp = { 0, 0, 0, doc };
  4844. int
  4845. main (int argc, char **argv)
  4846. {
  4847. argp_parse (&argp, argc, argv, 0, 0, 0);
  4848. exit (0);
  4849. }
  4850. 
  4851. File: libc.info, Node: Argp Example 3, Next: Argp Example 4, Prev: Argp Example 2, Up: Argp Examples
  4852. 25.3.11.3 A Program Using Argp with User Options
  4853. ................................................
  4854. This program uses the same features as example 2, adding user options
  4855. and arguments.
  4856. We now use the first four fields in ‘argp’ (*note Argp Parsers::) and
  4857. specify ‘parse_opt’ as the parser function. *Note Argp Parser
  4858. Functions::.
  4859. Note that in this example, ‘main’ uses a structure to communicate
  4860. with the ‘parse_opt’ function, a pointer to which it passes in the
  4861. ‘input’ argument to ‘argp_parse’. *Note Argp::. It is retrieved by
  4862. ‘parse_opt’ through the ‘input’ field in its ‘state’ argument. *Note
  4863. Argp Parsing State::. Of course, it’s also possible to use global
  4864. variables instead, but using a structure like this is somewhat more
  4865. flexible and clean.
  4866. /* This program uses the same features as example 2, and uses options and
  4867. arguments.
  4868. We now use the first four fields in ARGP, so here’s a description of them:
  4869. OPTIONS – A pointer to a vector of struct argp_option (see below)
  4870. PARSER – A function to parse a single option, called by argp
  4871. ARGS_DOC – A string describing how the non-option arguments should look
  4872. DOC – A descriptive string about this program; if it contains a
  4873. vertical tab character (\v), the part after it will be
  4874. printed *following* the options
  4875. The function PARSER takes the following arguments:
  4876. KEY – An integer specifying which option this is (taken
  4877. from the KEY field in each struct argp_option), or
  4878. a special key specifying something else; the only
  4879. special keys we use here are ARGP_KEY_ARG, meaning
  4880. a non-option argument, and ARGP_KEY_END, meaning
  4881. that all arguments have been parsed
  4882. ARG – For an option KEY, the string value of its
  4883. argument, or NULL if it has none
  4884. STATE– A pointer to a struct argp_state, containing
  4885. various useful information about the parsing state; used here
  4886. are the INPUT field, which reflects the INPUT argument to
  4887. argp_parse, and the ARG_NUM field, which is the number of the
  4888. current non-option argument being parsed
  4889. It should return either 0, meaning success, ARGP_ERR_UNKNOWN, meaning the
  4890. given KEY wasn’t recognized, or an errno value indicating some other
  4891. error.
  4892. Note that in this example, main uses a structure to communicate with the
  4893. parse_opt function, a pointer to which it passes in the INPUT argument to
  4894. argp_parse. Of course, it’s also possible to use global variables
  4895. instead, but this is somewhat more flexible.
  4896. The OPTIONS field contains a pointer to a vector of struct argp_option’s;
  4897. that structure has the following fields (if you assign your option
  4898. structures using array initialization like this example, unspecified
  4899. fields will be defaulted to 0, and need not be specified):
  4900. NAME – The name of this option’s long option (may be zero)
  4901. KEY – The KEY to pass to the PARSER function when parsing this option,
  4902. *and* the name of this option’s short option, if it is a
  4903. printable ascii character
  4904. ARG – The name of this option’s argument, if any
  4905. FLAGS – Flags describing this option; some of them are:
  4906. OPTION_ARG_OPTIONAL – The argument to this option is optional
  4907. OPTION_ALIAS – This option is an alias for the
  4908. previous option
  4909. OPTION_HIDDEN – Don’t show this option in –help output
  4910. DOC – A documentation string for this option, shown in –help output
  4911. An options vector should be terminated by an option with all fields zero. */
  4912. #include <stdlib.h>
  4913. #include <argp.h>
  4914. const char *argp_program_version =
  4915. "argp-ex3 1.0";
  4916. const char *argp_program_bug_address =
  4917. "<bug-gnu-utils@gnu.org>";
  4918. /* Program documentation. */
  4919. static char doc[] =
  4920. "Argp example #3 -- a program with options and arguments using argp";
  4921. /* A description of the arguments we accept. */
  4922. static char args_doc[] = "ARG1 ARG2";
  4923. /* The options we understand. */
  4924. static struct argp_option options[] = {
  4925. {"verbose", 'v', 0, 0, "Produce verbose output" },
  4926. {"quiet", 'q', 0, 0, "Don't produce any output" },
  4927. {"silent", 's', 0, OPTION_ALIAS },
  4928. {"output", 'o', "FILE", 0,
  4929. "Output to FILE instead of standard output" },
  4930. { 0 }
  4931. };
  4932. /* Used by ‘main’ to communicate with ‘parse_opt’. */
  4933. struct arguments
  4934. {
  4935. char *args[2]; /* ARG1 & ARG2 */
  4936. int silent, verbose;
  4937. char *output_file;
  4938. };
  4939. /* Parse a single option. */
  4940. static error_t
  4941. parse_opt (int key, char *arg, struct argp_state *state)
  4942. {
  4943. /* Get the INPUT argument from ‘argp_parse’, which we
  4944. know is a pointer to our arguments structure. */
  4945. struct arguments *arguments = state->input;
  4946. switch (key)
  4947. {
  4948. case 'q': case 's':
  4949. arguments->silent = 1;
  4950. break;
  4951. case 'v':
  4952. arguments->verbose = 1;
  4953. break;
  4954. case 'o':
  4955. arguments->output_file = arg;
  4956. break;
  4957. case ARGP_KEY_ARG:
  4958. if (state->arg_num >= 2)
  4959. /* Too many arguments. */
  4960. argp_usage (state);
  4961. arguments->args[state->arg_num] = arg;
  4962. break;
  4963. case ARGP_KEY_END:
  4964. if (state->arg_num < 2)
  4965. /* Not enough arguments. */
  4966. argp_usage (state);
  4967. break;
  4968. default:
  4969. return ARGP_ERR_UNKNOWN;
  4970. }
  4971. return 0;
  4972. }
  4973. /* Our argp parser. */
  4974. static struct argp argp = { options, parse_opt, args_doc, doc };
  4975. int
  4976. main (int argc, char **argv)
  4977. {
  4978. struct arguments arguments;
  4979. /* Default values. */
  4980. arguments.silent = 0;
  4981. arguments.verbose = 0;
  4982. arguments.output_file = "-";
  4983. /* Parse our arguments; every option seen by ‘parse_opt’ will
  4984. be reflected in ‘arguments’. */
  4985. argp_parse (&argp, argc, argv, 0, 0, &arguments);
  4986. printf ("ARG1 = %s\nARG2 = %s\nOUTPUT_FILE = %s\n"
  4987. "VERBOSE = %s\nSILENT = %s\n",
  4988. arguments.args[0], arguments.args[1],
  4989. arguments.output_file,
  4990. arguments.verbose ? "yes" : "no",
  4991. arguments.silent ? "yes" : "no");
  4992. exit (0);
  4993. }
  4994. 
  4995. File: libc.info, Node: Argp Example 4, Prev: Argp Example 3, Up: Argp Examples
  4996. 25.3.11.4 A Program Using Multiple Combined Argp Parsers
  4997. ........................................................
  4998. This program uses the same features as example 3, but has more options,
  4999. and presents more structure in the ‘--help’ output. It also illustrates
  5000. how you can ‘steal’ the remainder of the input arguments past a certain
  5001. point for programs that accept a list of items. It also illustrates the
  5002. KEY value ‘ARGP_KEY_NO_ARGS’, which is only given if no non-option
  5003. arguments were supplied to the program. *Note Argp Special Keys::.
  5004. For structuring help output, two features are used: _headers_ and a
  5005. two part option string. The _headers_ are entries in the options
  5006. vector. *Note Argp Option Vectors::. The first four fields are zero.
  5007. The two part documentation string are in the variable ‘doc’, which
  5008. allows documentation both before and after the options. *Note Argp
  5009. Parsers::, the two parts of ‘doc’ are separated by a vertical-tab
  5010. character (‘'\v'’, or ‘'\013'’). By convention, the documentation
  5011. before the options is a short string stating what the program does, and
  5012. after any options it is longer, describing the behavior in more detail.
  5013. All documentation strings are automatically filled for output, although
  5014. newlines may be included to force a line break at a particular point.
  5015. In addition, documentation strings are passed to the ‘gettext’ function,
  5016. for possible translation into the current locale.
  5017. /* This program uses the same features as example 3, but has more
  5018. options, and somewhat more structure in the -help output. It
  5019. also shows how you can ‘steal’ the remainder of the input
  5020. arguments past a certain point, for programs that accept a
  5021. list of items. It also shows the special argp KEY value
  5022. ARGP_KEY_NO_ARGS, which is only given if no non-option
  5023. arguments were supplied to the program.
  5024. For structuring the help output, two features are used,
  5025. *headers* which are entries in the options vector with the
  5026. first four fields being zero, and a two part documentation
  5027. string (in the variable DOC), which allows documentation both
  5028. before and after the options; the two parts of DOC are
  5029. separated by a vertical-tab character (’\v’, or ’\013’). By
  5030. convention, the documentation before the options is just a
  5031. short string saying what the program does, and that afterwards
  5032. is longer, describing the behavior in more detail. All
  5033. documentation strings are automatically filled for output,
  5034. although newlines may be included to force a line break at a
  5035. particular point. All documentation strings are also passed to
  5036. the ‘gettext’ function, for possible translation into the
  5037. current locale. */
  5038. #include <stdlib.h>
  5039. #include <error.h>
  5040. #include <argp.h>
  5041. const char *argp_program_version =
  5042. "argp-ex4 1.0";
  5043. const char *argp_program_bug_address =
  5044. "<bug-gnu-utils@prep.ai.mit.edu>";
  5045. /* Program documentation. */
  5046. static char doc[] =
  5047. "Argp example #4 -- a program with somewhat more complicated\
  5048. options\
  5049. \vThis part of the documentation comes *after* the options;\
  5050. note that the text is automatically filled, but it's possible\
  5051. to force a line-break, e.g.\n<-- here.";
  5052. /* A description of the arguments we accept. */
  5053. static char args_doc[] = "ARG1 [STRING...]";
  5054. /* Keys for options without short-options. */
  5055. #define OPT_ABORT 1 /* –abort */
  5056. /* The options we understand. */
  5057. static struct argp_option options[] = {
  5058. {"verbose", 'v', 0, 0, "Produce verbose output" },
  5059. {"quiet", 'q', 0, 0, "Don't produce any output" },
  5060. {"silent", 's', 0, OPTION_ALIAS },
  5061. {"output", 'o', "FILE", 0,
  5062. "Output to FILE instead of standard output" },
  5063. {0,0,0,0, "The following options should be grouped together:" },
  5064. {"repeat", 'r', "COUNT", OPTION_ARG_OPTIONAL,
  5065. "Repeat the output COUNT (default 10) times"},
  5066. {"abort", OPT_ABORT, 0, 0, "Abort before showing any output"},
  5067. { 0 }
  5068. };
  5069. /* Used by ‘main’ to communicate with ‘parse_opt’. */
  5070. struct arguments
  5071. {
  5072. char *arg1; /* ARG1 */
  5073. char **strings; /* [STRING...] */
  5074. int silent, verbose, abort; /* ‘-s’, ‘-v’, ‘--abort’ */
  5075. char *output_file; /* FILE arg to ‘--output’ */
  5076. int repeat_count; /* COUNT arg to ‘--repeat’ */
  5077. };
  5078. /* Parse a single option. */
  5079. static error_t
  5080. parse_opt (int key, char *arg, struct argp_state *state)
  5081. {
  5082. /* Get the ‘input’ argument from ‘argp_parse’, which we
  5083. know is a pointer to our arguments structure. */
  5084. struct arguments *arguments = state->input;
  5085. switch (key)
  5086. {
  5087. case 'q': case 's':
  5088. arguments->silent = 1;
  5089. break;
  5090. case 'v':
  5091. arguments->verbose = 1;
  5092. break;
  5093. case 'o':
  5094. arguments->output_file = arg;
  5095. break;
  5096. case 'r':
  5097. arguments->repeat_count = arg ? atoi (arg) : 10;
  5098. break;
  5099. case OPT_ABORT:
  5100. arguments->abort = 1;
  5101. break;
  5102. case ARGP_KEY_NO_ARGS:
  5103. argp_usage (state);
  5104. case ARGP_KEY_ARG:
  5105. /* Here we know that ‘state->arg_num == 0’, since we
  5106. force argument parsing to end before any more arguments can
  5107. get here. */
  5108. arguments->arg1 = arg;
  5109. /* Now we consume all the rest of the arguments.
  5110. ‘state->next’ is the index in ‘state->argv’ of the
  5111. next argument to be parsed, which is the first STRING
  5112. we’re interested in, so we can just use
  5113. ‘&state->argv[state->next]’ as the value for
  5114. arguments->strings.
  5115. _In addition_, by setting ‘state->next’ to the end
  5116. of the arguments, we can force argp to stop parsing here and
  5117. return. */
  5118. arguments->strings = &state->argv[state->next];
  5119. state->next = state->argc;
  5120. break;
  5121. default:
  5122. return ARGP_ERR_UNKNOWN;
  5123. }
  5124. return 0;
  5125. }
  5126. /* Our argp parser. */
  5127. static struct argp argp = { options, parse_opt, args_doc, doc };
  5128. int
  5129. main (int argc, char **argv)
  5130. {
  5131. int i, j;
  5132. struct arguments arguments;
  5133. /* Default values. */
  5134. arguments.silent = 0;
  5135. arguments.verbose = 0;
  5136. arguments.output_file = "-";
  5137. arguments.repeat_count = 1;
  5138. arguments.abort = 0;
  5139. /* Parse our arguments; every option seen by ‘parse_opt’ will be
  5140. reflected in ‘arguments’. */
  5141. argp_parse (&argp, argc, argv, 0, 0, &arguments);
  5142. if (arguments.abort)
  5143. error (10, 0, "ABORTED");
  5144. for (i = 0; i < arguments.repeat_count; i++)
  5145. {
  5146. printf ("ARG1 = %s\n", arguments.arg1);
  5147. printf ("STRINGS = ");
  5148. for (j = 0; arguments.strings[j]; j++)
  5149. printf (j == 0 ? "%s" : ", %s", arguments.strings[j]);
  5150. printf ("\n");
  5151. printf ("OUTPUT_FILE = %s\nVERBOSE = %s\nSILENT = %s\n",
  5152. arguments.output_file,
  5153. arguments.verbose ? "yes" : "no",
  5154. arguments.silent ? "yes" : "no");
  5155. }
  5156. exit (0);
  5157. }
  5158. 
  5159. File: libc.info, Node: Argp User Customization, Prev: Argp Examples, Up: Argp
  5160. 25.3.12 Argp User Customization
  5161. -------------------------------
  5162. The formatting of argp ‘--help’ output may be controlled to some extent
  5163. by a program’s users, by setting the ‘ARGP_HELP_FMT’ environment
  5164. variable to a comma-separated list of tokens. Whitespace is ignored:
  5165. ‘dup-args’
  5166. ‘no-dup-args’
  5167. These turn “duplicate-argument-mode” on or off. In duplicate
  5168. argument mode, if an option that accepts an argument has multiple
  5169. names, the argument is shown for each name. Otherwise, it is only
  5170. shown for the first long option. A note is subsequently printed so
  5171. the user knows that it applies to other names as well. The default
  5172. is ‘no-dup-args’, which is less consistent, but prettier.
  5173. ‘dup-args-note’
  5174. ‘no-dup-args-note’
  5175. These will enable or disable the note informing the user of
  5176. suppressed option argument duplication. The default is
  5177. ‘dup-args-note’.
  5178. ‘short-opt-col=N’
  5179. This prints the first short option in column N. The default is 2.
  5180. ‘long-opt-col=N’
  5181. This prints the first long option in column N. The default is 6.
  5182. ‘doc-opt-col=N’
  5183. This prints ‘documentation options’ (*note Argp Option Flags::) in
  5184. column N. The default is 2.
  5185. ‘opt-doc-col=N’
  5186. This prints the documentation for options starting in column N.
  5187. The default is 29.
  5188. ‘header-col=N’
  5189. This will indent the group headers that document groups of options
  5190. to column N. The default is 1.
  5191. ‘usage-indent=N’
  5192. This will indent continuation lines in ‘Usage:’ messages to column
  5193. N. The default is 12.
  5194. ‘rmargin=N’
  5195. This will word wrap help output at or before column N. The default
  5196. is 79.
  5197. * Menu:
  5198. * Suboptions::
  5199. 
  5200. File: libc.info, Node: Suboptions, Next: Suboptions Example, Prev: Argp, Up: Parsing Program Arguments
  5201. 25.3.12.1 Parsing of Suboptions
  5202. ...............................
  5203. Having a single level of options is sometimes not enough. There might
  5204. be too many options which have to be available or a set of options is
  5205. closely related.
  5206. For this case some programs use suboptions. One of the most
  5207. prominent programs is certainly ‘mount’(8). The ‘-o’ option take one
  5208. argument which itself is a comma separated list of options. To ease the
  5209. programming of code like this the function ‘getsubopt’ is available.
  5210. -- Function: int getsubopt (char **OPTIONP, char *const *TOKENS, char
  5211. **VALUEP)
  5212. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5213. Concepts::.
  5214. The OPTIONP parameter must be a pointer to a variable containing
  5215. the address of the string to process. When the function returns,
  5216. the reference is updated to point to the next suboption or to the
  5217. terminating ‘\0’ character if there are no more suboptions
  5218. available.
  5219. The TOKENS parameter references an array of strings containing the
  5220. known suboptions. All strings must be ‘\0’ terminated and to mark
  5221. the end a null pointer must be stored. When ‘getsubopt’ finds a
  5222. possible legal suboption it compares it with all strings available
  5223. in the TOKENS array and returns the index in the string as the
  5224. indicator.
  5225. In case the suboption has an associated value introduced by a ‘=’
  5226. character, a pointer to the value is returned in VALUEP. The
  5227. string is ‘\0’ terminated. If no argument is available VALUEP is
  5228. set to the null pointer. By doing this the caller can check
  5229. whether a necessary value is given or whether no unexpected value
  5230. is present.
  5231. In case the next suboption in the string is not mentioned in the
  5232. TOKENS array the starting address of the suboption including a
  5233. possible value is returned in VALUEP and the return value of the
  5234. function is ‘-1’.
  5235. 
  5236. File: libc.info, Node: Suboptions Example, Prev: Suboptions, Up: Parsing Program Arguments
  5237. 25.3.13 Parsing of Suboptions Example
  5238. -------------------------------------
  5239. The code which might appear in the ‘mount’(8) program is a perfect
  5240. example of the use of ‘getsubopt’:
  5241. #include <stdio.h>
  5242. #include <stdlib.h>
  5243. #include <unistd.h>
  5244. int do_all;
  5245. const char *type;
  5246. int read_size;
  5247. int write_size;
  5248. int read_only;
  5249. enum
  5250. {
  5251. RO_OPTION = 0,
  5252. RW_OPTION,
  5253. READ_SIZE_OPTION,
  5254. WRITE_SIZE_OPTION,
  5255. THE_END
  5256. };
  5257. const char *mount_opts[] =
  5258. {
  5259. [RO_OPTION] = "ro",
  5260. [RW_OPTION] = "rw",
  5261. [READ_SIZE_OPTION] = "rsize",
  5262. [WRITE_SIZE_OPTION] = "wsize",
  5263. [THE_END] = NULL
  5264. };
  5265. int
  5266. main (int argc, char **argv)
  5267. {
  5268. char *subopts, *value;
  5269. int opt;
  5270. while ((opt = getopt (argc, argv, "at:o:")) != -1)
  5271. switch (opt)
  5272. {
  5273. case 'a':
  5274. do_all = 1;
  5275. break;
  5276. case 't':
  5277. type = optarg;
  5278. break;
  5279. case 'o':
  5280. subopts = optarg;
  5281. while (*subopts != '\0')
  5282. switch (getsubopt (&subopts, mount_opts, &value))
  5283. {
  5284. case RO_OPTION:
  5285. read_only = 1;
  5286. break;
  5287. case RW_OPTION:
  5288. read_only = 0;
  5289. break;
  5290. case READ_SIZE_OPTION:
  5291. if (value == NULL)
  5292. abort ();
  5293. read_size = atoi (value);
  5294. break;
  5295. case WRITE_SIZE_OPTION:
  5296. if (value == NULL)
  5297. abort ();
  5298. write_size = atoi (value);
  5299. break;
  5300. default:
  5301. /* Unknown suboption. */
  5302. printf ("Unknown suboption `%s'\n", value);
  5303. break;
  5304. }
  5305. break;
  5306. default:
  5307. abort ();
  5308. }
  5309. /* Do the real work. */
  5310. return 0;
  5311. }
  5312. 
  5313. File: libc.info, Node: Environment Variables, Next: Auxiliary Vector, Prev: Program Arguments, Up: Program Basics
  5314. 25.4 Environment Variables
  5315. ==========================
  5316. When a program is executed, it receives information about the context in
  5317. which it was invoked in two ways. The first mechanism uses the ARGV and
  5318. ARGC arguments to its ‘main’ function, and is discussed in *note Program
  5319. Arguments::. The second mechanism uses “environment variables” and is
  5320. discussed in this section.
  5321. The ARGV mechanism is typically used to pass command-line arguments
  5322. specific to the particular program being invoked. The environment, on
  5323. the other hand, keeps track of information that is shared by many
  5324. programs, changes infrequently, and that is less frequently used.
  5325. The environment variables discussed in this section are the same
  5326. environment variables that you set using assignments and the ‘export’
  5327. command in the shell. Programs executed from the shell inherit all of
  5328. the environment variables from the shell.
  5329. Standard environment variables are used for information about the
  5330. user’s home directory, terminal type, current locale, and so on; you can
  5331. define additional variables for other purposes. The set of all
  5332. environment variables that have values is collectively known as the
  5333. “environment”.
  5334. Names of environment variables are case-sensitive and must not
  5335. contain the character ‘=’. System-defined environment variables are
  5336. invariably uppercase.
  5337. The values of environment variables can be anything that can be
  5338. represented as a string. A value must not contain an embedded null
  5339. character, since this is assumed to terminate the string.
  5340. * Menu:
  5341. * Environment Access:: How to get and set the values of
  5342. environment variables.
  5343. * Standard Environment:: These environment variables have
  5344. standard interpretations.
  5345. 
  5346. File: libc.info, Node: Environment Access, Next: Standard Environment, Up: Environment Variables
  5347. 25.4.1 Environment Access
  5348. -------------------------
  5349. The value of an environment variable can be accessed with the ‘getenv’
  5350. function. This is declared in the header file ‘stdlib.h’.
  5351. Libraries should use ‘secure_getenv’ instead of ‘getenv’, so that
  5352. they do not accidentally use untrusted environment variables.
  5353. Modifications of environment variables are not allowed in multi-threaded
  5354. programs. The ‘getenv’ and ‘secure_getenv’ functions can be safely used
  5355. in multi-threaded programs.
  5356. -- Function: char * getenv (const char *NAME)
  5357. Preliminary: | MT-Safe env | AS-Safe | AC-Safe | *Note POSIX Safety
  5358. Concepts::.
  5359. This function returns a string that is the value of the environment
  5360. variable NAME. You must not modify this string. In some non-Unix
  5361. systems not using the GNU C Library, it might be overwritten by
  5362. subsequent calls to ‘getenv’ (but not by any other library
  5363. function). If the environment variable NAME is not defined, the
  5364. value is a null pointer.
  5365. -- Function: char * secure_getenv (const char *NAME)
  5366. Preliminary: | MT-Safe env | AS-Safe | AC-Safe | *Note POSIX Safety
  5367. Concepts::.
  5368. This function is similar to ‘getenv’, but it returns a null pointer
  5369. if the environment is untrusted. This happens when the program
  5370. file has SUID or SGID bits set. General-purpose libraries should
  5371. always prefer this function over ‘getenv’ to avoid vulnerabilities
  5372. if the library is referenced from a SUID/SGID program.
  5373. This function is a GNU extension.
  5374. -- Function: int putenv (char *STRING)
  5375. Preliminary: | MT-Unsafe const:env | AS-Unsafe heap lock |
  5376. AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5377. The ‘putenv’ function adds or removes definitions from the
  5378. environment. If the STRING is of the form ‘NAME=VALUE’, the
  5379. definition is added to the environment. Otherwise, the STRING is
  5380. interpreted as the name of an environment variable, and any
  5381. definition for this variable in the environment is removed.
  5382. If the function is successful it returns ‘0’. Otherwise the return
  5383. value is nonzero and ‘errno’ is set to indicate the error.
  5384. The difference to the ‘setenv’ function is that the exact string
  5385. given as the parameter STRING is put into the environment. If the
  5386. user should change the string after the ‘putenv’ call this will
  5387. reflect automatically in the environment. This also requires that
  5388. STRING not be an automatic variable whose scope is left before the
  5389. variable is removed from the environment. The same applies of
  5390. course to dynamically allocated variables which are freed later.
  5391. This function is part of the extended Unix interface. You should
  5392. define _XOPEN_SOURCE before including any header.
  5393. -- Function: int setenv (const char *NAME, const char *VALUE, int
  5394. REPLACE)
  5395. Preliminary: | MT-Unsafe const:env | AS-Unsafe heap lock |
  5396. AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5397. The ‘setenv’ function can be used to add a new definition to the
  5398. environment. The entry with the name NAME is replaced by the value
  5399. ‘NAME=VALUE’. Please note that this is also true if VALUE is the
  5400. empty string. To do this a new string is created and the strings
  5401. NAME and VALUE are copied. A null pointer for the VALUE parameter
  5402. is illegal. If the environment already contains an entry with key
  5403. NAME the REPLACE parameter controls the action. If replace is
  5404. zero, nothing happens. Otherwise the old entry is replaced by the
  5405. new one.
  5406. Please note that you cannot remove an entry completely using this
  5407. function.
  5408. If the function is successful it returns ‘0’. Otherwise the
  5409. environment is unchanged and the return value is ‘-1’ and ‘errno’
  5410. is set.
  5411. This function was originally part of the BSD library but is now
  5412. part of the Unix standard.
  5413. -- Function: int unsetenv (const char *NAME)
  5414. Preliminary: | MT-Unsafe const:env | AS-Unsafe lock | AC-Unsafe
  5415. lock | *Note POSIX Safety Concepts::.
  5416. Using this function one can remove an entry completely from the
  5417. environment. If the environment contains an entry with the key
  5418. NAME this whole entry is removed. A call to this function is
  5419. equivalent to a call to ‘putenv’ when the VALUE part of the string
  5420. is empty.
  5421. The function returns ‘-1’ if NAME is a null pointer, points to an
  5422. empty string, or points to a string containing a ‘=’ character. It
  5423. returns ‘0’ if the call succeeded.
  5424. This function was originally part of the BSD library but is now
  5425. part of the Unix standard. The BSD version had no return value,
  5426. though.
  5427. There is one more function to modify the whole environment. This
  5428. function is said to be used in the POSIX.9 (POSIX bindings for Fortran
  5429. 77) and so one should expect it did made it into POSIX.1. But this
  5430. never happened. But we still provide this function as a GNU extension
  5431. to enable writing standard compliant Fortran environments.
  5432. -- Function: int clearenv (void)
  5433. Preliminary: | MT-Unsafe const:env | AS-Unsafe heap lock |
  5434. AC-Unsafe lock mem | *Note POSIX Safety Concepts::.
  5435. The ‘clearenv’ function removes all entries from the environment.
  5436. Using ‘putenv’ and ‘setenv’ new entries can be added again later.
  5437. If the function is successful it returns ‘0’. Otherwise the return
  5438. value is nonzero.
  5439. You can deal directly with the underlying representation of
  5440. environment objects to add more variables to the environment (for
  5441. example, to communicate with another program you are about to execute;
  5442. *note Executing a File::).
  5443. -- Variable: char ** environ
  5444. The environment is represented as an array of strings. Each string
  5445. is of the format ‘NAME=VALUE’. The order in which strings appear
  5446. in the environment is not significant, but the same NAME must not
  5447. appear more than once. The last element of the array is a null
  5448. pointer.
  5449. This variable is declared in the header file ‘unistd.h’.
  5450. If you just want to get the value of an environment variable, use
  5451. ‘getenv’.
  5452. Unix systems, and GNU systems, pass the initial value of ‘environ’ as
  5453. the third argument to ‘main’. *Note Program Arguments::.
  5454. 
  5455. File: libc.info, Node: Standard Environment, Prev: Environment Access, Up: Environment Variables
  5456. 25.4.2 Standard Environment Variables
  5457. -------------------------------------
  5458. These environment variables have standard meanings. This doesn’t mean
  5459. that they are always present in the environment; but if these variables
  5460. _are_ present, they have these meanings. You shouldn’t try to use these
  5461. environment variable names for some other purpose.
  5462. ‘HOME’
  5463. This is a string representing the user’s “home directory”, or
  5464. initial default working directory.
  5465. The user can set ‘HOME’ to any value. If you need to make sure to
  5466. obtain the proper home directory for a particular user, you should
  5467. not use ‘HOME’; instead, look up the user’s name in the user
  5468. database (*note User Database::).
  5469. For most purposes, it is better to use ‘HOME’, precisely because
  5470. this lets the user specify the value.
  5471. ‘LOGNAME’
  5472. This is the name that the user used to log in. Since the value in
  5473. the environment can be tweaked arbitrarily, this is not a reliable
  5474. way to identify the user who is running a program; a function like
  5475. ‘getlogin’ (*note Who Logged In::) is better for that purpose.
  5476. For most purposes, it is better to use ‘LOGNAME’, precisely because
  5477. this lets the user specify the value.
  5478. ‘PATH’
  5479. A “path” is a sequence of directory names which is used for
  5480. searching for a file. The variable ‘PATH’ holds a path used for
  5481. searching for programs to be run.
  5482. The ‘execlp’ and ‘execvp’ functions (*note Executing a File::) use
  5483. this environment variable, as do many shells and other utilities
  5484. which are implemented in terms of those functions.
  5485. The syntax of a path is a sequence of directory names separated by
  5486. colons. An empty string instead of a directory name stands for the
  5487. current directory (*note Working Directory::).
  5488. A typical value for this environment variable might be a string
  5489. like:
  5490. :/bin:/etc:/usr/bin:/usr/new/X11:/usr/new:/usr/local/bin
  5491. This means that if the user tries to execute a program named ‘foo’,
  5492. the system will look for files named ‘foo’, ‘/bin/foo’, ‘/etc/foo’,
  5493. and so on. The first of these files that exists is the one that is
  5494. executed.
  5495. ‘TERM’
  5496. This specifies the kind of terminal that is receiving program
  5497. output. Some programs can make use of this information to take
  5498. advantage of special escape sequences or terminal modes supported
  5499. by particular kinds of terminals. Many programs which use the
  5500. termcap library (*note Find: (termcap)Finding a Terminal
  5501. Description.) use the ‘TERM’ environment variable, for example.
  5502. ‘TZ’
  5503. This specifies the time zone. *Note TZ Variable::, for information
  5504. about the format of this string and how it is used.
  5505. ‘LANG’
  5506. This specifies the default locale to use for attribute categories
  5507. where neither ‘LC_ALL’ nor the specific environment variable for
  5508. that category is set. *Note Locales::, for more information about
  5509. locales.
  5510. ‘LC_ALL’
  5511. If this environment variable is set it overrides the selection for
  5512. all the locales done using the other ‘LC_*’ environment variables.
  5513. The value of the other ‘LC_*’ environment variables is simply
  5514. ignored in this case.
  5515. ‘LC_COLLATE’
  5516. This specifies what locale to use for string sorting.
  5517. ‘LC_CTYPE’
  5518. This specifies what locale to use for character sets and character
  5519. classification.
  5520. ‘LC_MESSAGES’
  5521. This specifies what locale to use for printing messages and to
  5522. parse responses.
  5523. ‘LC_MONETARY’
  5524. This specifies what locale to use for formatting monetary values.
  5525. ‘LC_NUMERIC’
  5526. This specifies what locale to use for formatting numbers.
  5527. ‘LC_TIME’
  5528. This specifies what locale to use for formatting date/time values.
  5529. ‘NLSPATH’
  5530. This specifies the directories in which the ‘catopen’ function
  5531. looks for message translation catalogs.
  5532. ‘_POSIX_OPTION_ORDER’
  5533. If this environment variable is defined, it suppresses the usual
  5534. reordering of command line arguments by ‘getopt’ and ‘argp_parse’.
  5535. *Note Argument Syntax::.
  5536. 
  5537. File: libc.info, Node: Auxiliary Vector, Next: System Calls, Prev: Environment Variables, Up: Program Basics
  5538. 25.5 Auxiliary Vector
  5539. =====================
  5540. When a program is executed, it receives information from the operating
  5541. system about the environment in which it is operating. The form of this
  5542. information is a table of key-value pairs, where the keys are from the
  5543. set of ‘AT_’ values in ‘elf.h’. Some of the data is provided by the
  5544. kernel for libc consumption, and may be obtained by ordinary interfaces,
  5545. such as ‘sysconf’. However, on a platform-by-platform basis there may
  5546. be information that is not available any other way.
  5547. 25.5.1 Definition of ‘getauxval’
  5548. --------------------------------
  5549. -- Function: unsigned long int getauxval (unsigned long int TYPE)
  5550. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5551. Concepts::.
  5552. This function is used to inquire about the entries in the auxiliary
  5553. vector. The TYPE argument should be one of the ‘AT_’ symbols
  5554. defined in ‘elf.h’. If a matching entry is found, the value is
  5555. returned; if the entry is not found, zero is returned and ‘errno’
  5556. is set to ‘ENOENT’.
  5557. For some platforms, the key ‘AT_HWCAP’ is the easiest way to inquire
  5558. about any instruction set extensions available at runtime. In this
  5559. case, there will (of necessity) be a platform-specific set of ‘HWCAP_’
  5560. values masked together that describe the capabilities of the cpu on
  5561. which the program is being executed.
  5562. 
  5563. File: libc.info, Node: System Calls, Next: Program Termination, Prev: Auxiliary Vector, Up: Program Basics
  5564. 25.6 System Calls
  5565. =================
  5566. A system call is a request for service that a program makes of the
  5567. kernel. The service is generally something that only the kernel has the
  5568. privilege to do, such as doing I/O. Programmers don’t normally need to
  5569. be concerned with system calls because there are functions in the GNU C
  5570. Library to do virtually everything that system calls do. These
  5571. functions work by making system calls themselves. For example, there is
  5572. a system call that changes the permissions of a file, but you don’t need
  5573. to know about it because you can just use the GNU C Library’s ‘chmod’
  5574. function.
  5575. System calls are sometimes called kernel calls.
  5576. However, there are times when you want to make a system call
  5577. explicitly, and for that, the GNU C Library provides the ‘syscall’
  5578. function. ‘syscall’ is harder to use and less portable than functions
  5579. like ‘chmod’, but easier and more portable than coding the system call
  5580. in assembler instructions.
  5581. ‘syscall’ is most useful when you are working with a system call
  5582. which is special to your system or is newer than the GNU C Library you
  5583. are using. ‘syscall’ is implemented in an entirely generic way; the
  5584. function does not know anything about what a particular system call does
  5585. or even if it is valid.
  5586. The description of ‘syscall’ in this section assumes a certain
  5587. protocol for system calls on the various platforms on which the GNU C
  5588. Library runs. That protocol is not defined by any strong authority, but
  5589. we won’t describe it here either because anyone who is coding ‘syscall’
  5590. probably won’t accept anything less than kernel and C library source
  5591. code as a specification of the interface between them anyway.
  5592. ‘syscall’ is declared in ‘unistd.h’.
  5593. -- Function: long int syscall (long int SYSNO, ...)
  5594. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5595. Concepts::.
  5596. ‘syscall’ performs a generic system call.
  5597. SYSNO is the system call number. Each kind of system call is
  5598. identified by a number. Macros for all the possible system call
  5599. numbers are defined in ‘sys/syscall.h’
  5600. The remaining arguments are the arguments for the system call, in
  5601. order, and their meanings depend on the kind of system call. Each
  5602. kind of system call has a definite number of arguments, from zero
  5603. to five. If you code more arguments than the system call takes,
  5604. the extra ones to the right are ignored.
  5605. The return value is the return value from the system call, unless
  5606. the system call failed. In that case, ‘syscall’ returns ‘-1’ and
  5607. sets ‘errno’ to an error code that the system call returned. Note
  5608. that system calls do not return ‘-1’ when they succeed.
  5609. If you specify an invalid SYSNO, ‘syscall’ returns ‘-1’ with
  5610. ‘errno’ = ‘ENOSYS’.
  5611. Example:
  5612. #include <unistd.h>
  5613. #include <sys/syscall.h>
  5614. #include <errno.h>
  5615. ...
  5616. int rc;
  5617. rc = syscall(SYS_chmod, "/etc/passwd", 0444);
  5618. if (rc == -1)
  5619. fprintf(stderr, "chmod failed, errno = %d\n", errno);
  5620. This, if all the compatibility stars are aligned, is equivalent to
  5621. the following preferable code:
  5622. #include <sys/types.h>
  5623. #include <sys/stat.h>
  5624. #include <errno.h>
  5625. ...
  5626. int rc;
  5627. rc = chmod("/etc/passwd", 0444);
  5628. if (rc == -1)
  5629. fprintf(stderr, "chmod failed, errno = %d\n", errno);
  5630. 
  5631. File: libc.info, Node: Program Termination, Prev: System Calls, Up: Program Basics
  5632. 25.7 Program Termination
  5633. ========================
  5634. The usual way for a program to terminate is simply for its ‘main’
  5635. function to return. The “exit status value” returned from the ‘main’
  5636. function is used to report information back to the process’s parent
  5637. process or shell.
  5638. A program can also terminate normally by calling the ‘exit’ function.
  5639. In addition, programs can be terminated by signals; this is discussed
  5640. in more detail in *note Signal Handling::. The ‘abort’ function causes
  5641. a signal that kills the program.
  5642. * Menu:
  5643. * Normal Termination:: If a program calls ‘exit’, a
  5644. process terminates normally.
  5645. * Exit Status:: The ‘exit status’ provides information
  5646. about why the process terminated.
  5647. * Cleanups on Exit:: A process can run its own cleanup
  5648. functions upon normal termination.
  5649. * Aborting a Program:: The ‘abort’ function causes
  5650. abnormal program termination.
  5651. * Termination Internals:: What happens when a process terminates.
  5652. 
  5653. File: libc.info, Node: Normal Termination, Next: Exit Status, Up: Program Termination
  5654. 25.7.1 Normal Termination
  5655. -------------------------
  5656. A process terminates normally when its program signals it is done by
  5657. calling ‘exit’. Returning from ‘main’ is equivalent to calling ‘exit’,
  5658. and the value that ‘main’ returns is used as the argument to ‘exit’.
  5659. -- Function: void exit (int STATUS)
  5660. Preliminary: | MT-Unsafe race:exit | AS-Unsafe corrupt | AC-Unsafe
  5661. corrupt lock | *Note POSIX Safety Concepts::.
  5662. The ‘exit’ function tells the system that the program is done,
  5663. which causes it to terminate the process.
  5664. STATUS is the program’s exit status, which becomes part of the
  5665. process’ termination status. This function does not return.
  5666. Normal termination causes the following actions:
  5667. 1. Functions that were registered with the ‘atexit’ or ‘on_exit’
  5668. functions are called in the reverse order of their registration.
  5669. This mechanism allows your application to specify its own “cleanup”
  5670. actions to be performed at program termination. Typically, this is
  5671. used to do things like saving program state information in a file,
  5672. or unlocking locks in shared data bases.
  5673. 2. All open streams are closed, writing out any buffered output data.
  5674. See *note Closing Streams::. In addition, temporary files opened
  5675. with the ‘tmpfile’ function are removed; see *note Temporary
  5676. Files::.
  5677. 3. ‘_exit’ is called, terminating the program. *Note Termination
  5678. Internals::.
  5679. 
  5680. File: libc.info, Node: Exit Status, Next: Cleanups on Exit, Prev: Normal Termination, Up: Program Termination
  5681. 25.7.2 Exit Status
  5682. ------------------
  5683. When a program exits, it can return to the parent process a small amount
  5684. of information about the cause of termination, using the “exit status”.
  5685. This is a value between 0 and 255 that the exiting process passes as an
  5686. argument to ‘exit’.
  5687. Normally you should use the exit status to report very broad
  5688. information about success or failure. You can’t provide a lot of detail
  5689. about the reasons for the failure, and most parent processes would not
  5690. want much detail anyway.
  5691. There are conventions for what sorts of status values certain
  5692. programs should return. The most common convention is simply 0 for
  5693. success and 1 for failure. Programs that perform comparison use a
  5694. different convention: they use status 1 to indicate a mismatch, and
  5695. status 2 to indicate an inability to compare. Your program should
  5696. follow an existing convention if an existing convention makes sense for
  5697. it.
  5698. A general convention reserves status values 128 and up for special
  5699. purposes. In particular, the value 128 is used to indicate failure to
  5700. execute another program in a subprocess. This convention is not
  5701. universally obeyed, but it is a good idea to follow it in your programs.
  5702. *Warning:* Don’t try to use the number of errors as the exit status.
  5703. This is actually not very useful; a parent process would generally not
  5704. care how many errors occurred. Worse than that, it does not work,
  5705. because the status value is truncated to eight bits. Thus, if the
  5706. program tried to report 256 errors, the parent would receive a report of
  5707. 0 errors—that is, success.
  5708. For the same reason, it does not work to use the value of ‘errno’ as
  5709. the exit status—these can exceed 255.
  5710. *Portability note:* Some non-POSIX systems use different conventions
  5711. for exit status values. For greater portability, you can use the macros
  5712. ‘EXIT_SUCCESS’ and ‘EXIT_FAILURE’ for the conventional status value for
  5713. success and failure, respectively. They are declared in the file
  5714. ‘stdlib.h’.
  5715. -- Macro: int EXIT_SUCCESS
  5716. This macro can be used with the ‘exit’ function to indicate
  5717. successful program completion.
  5718. On POSIX systems, the value of this macro is ‘0’. On other
  5719. systems, the value might be some other (possibly non-constant)
  5720. integer expression.
  5721. -- Macro: int EXIT_FAILURE
  5722. This macro can be used with the ‘exit’ function to indicate
  5723. unsuccessful program completion in a general sense.
  5724. On POSIX systems, the value of this macro is ‘1’. On other
  5725. systems, the value might be some other (possibly non-constant)
  5726. integer expression. Other nonzero status values also indicate
  5727. failures. Certain programs use different nonzero status values to
  5728. indicate particular kinds of "non-success". For example, ‘diff’
  5729. uses status value ‘1’ to mean that the files are different, and ‘2’
  5730. or more to mean that there was difficulty in opening the files.
  5731. Don’t confuse a program’s exit status with a process’ termination
  5732. status. There are lots of ways a process can terminate besides having
  5733. its program finish. In the event that the process termination _is_
  5734. caused by program termination (i.e., ‘exit’), though, the program’s exit
  5735. status becomes part of the process’ termination status.
  5736. 
  5737. File: libc.info, Node: Cleanups on Exit, Next: Aborting a Program, Prev: Exit Status, Up: Program Termination
  5738. 25.7.3 Cleanups on Exit
  5739. -----------------------
  5740. Your program can arrange to run its own cleanup functions if normal
  5741. termination happens. If you are writing a library for use in various
  5742. application programs, then it is unreliable to insist that all
  5743. applications call the library’s cleanup functions explicitly before
  5744. exiting. It is much more robust to make the cleanup invisible to the
  5745. application, by setting up a cleanup function in the library itself
  5746. using ‘atexit’ or ‘on_exit’.
  5747. -- Function: int atexit (void (*FUNCTION) (void))
  5748. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock mem |
  5749. *Note POSIX Safety Concepts::.
  5750. The ‘atexit’ function registers the function FUNCTION to be called
  5751. at normal program termination. The FUNCTION is called with no
  5752. arguments.
  5753. The return value from ‘atexit’ is zero on success and nonzero if
  5754. the function cannot be registered.
  5755. -- Function: int on_exit (void (*FUNCTION)(int STATUS, void *ARG), void
  5756. *ARG)
  5757. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock mem |
  5758. *Note POSIX Safety Concepts::.
  5759. This function is a somewhat more powerful variant of ‘atexit’. It
  5760. accepts two arguments, a function FUNCTION and an arbitrary pointer
  5761. ARG. At normal program termination, the FUNCTION is called with
  5762. two arguments: the STATUS value passed to ‘exit’, and the ARG.
  5763. This function is included in the GNU C Library only for
  5764. compatibility for SunOS, and may not be supported by other
  5765. implementations.
  5766. Here’s a trivial program that illustrates the use of ‘exit’ and
  5767. ‘atexit’:
  5768. #include <stdio.h>
  5769. #include <stdlib.h>
  5770. void
  5771. bye (void)
  5772. {
  5773. puts ("Goodbye, cruel world....");
  5774. }
  5775. int
  5776. main (void)
  5777. {
  5778. atexit (bye);
  5779. exit (EXIT_SUCCESS);
  5780. }
  5781. When this program is executed, it just prints the message and exits.
  5782. 
  5783. File: libc.info, Node: Aborting a Program, Next: Termination Internals, Prev: Cleanups on Exit, Up: Program Termination
  5784. 25.7.4 Aborting a Program
  5785. -------------------------
  5786. You can abort your program using the ‘abort’ function. The prototype
  5787. for this function is in ‘stdlib.h’.
  5788. -- Function: void abort (void)
  5789. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt
  5790. | *Note POSIX Safety Concepts::.
  5791. The ‘abort’ function causes abnormal program termination. This
  5792. does not execute cleanup functions registered with ‘atexit’ or
  5793. ‘on_exit’.
  5794. This function actually terminates the process by raising a
  5795. ‘SIGABRT’ signal, and your program can include a handler to
  5796. intercept this signal; see *note Signal Handling::.
  5797. 
  5798. File: libc.info, Node: Termination Internals, Prev: Aborting a Program, Up: Program Termination
  5799. 25.7.5 Termination Internals
  5800. ----------------------------
  5801. The ‘_exit’ function is the primitive used for process termination by
  5802. ‘exit’. It is declared in the header file ‘unistd.h’.
  5803. -- Function: void _exit (int STATUS)
  5804. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5805. Concepts::.
  5806. The ‘_exit’ function is the primitive for causing a process to
  5807. terminate with status STATUS. Calling this function does not
  5808. execute cleanup functions registered with ‘atexit’ or ‘on_exit’.
  5809. -- Function: void _Exit (int STATUS)
  5810. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5811. Concepts::.
  5812. The ‘_Exit’ function is the ISO C equivalent to ‘_exit’. The ISO C
  5813. committee members were not sure whether the definitions of ‘_exit’
  5814. and ‘_Exit’ were compatible so they have not used the POSIX name.
  5815. This function was introduced in ISO C99 and is declared in
  5816. ‘stdlib.h’.
  5817. When a process terminates for any reason—either because the program
  5818. terminates, or as a result of a signal—the following things happen:
  5819. • All open file descriptors in the process are closed. *Note
  5820. Low-Level I/O::. Note that streams are not flushed automatically
  5821. when the process terminates; see *note I/O on Streams::.
  5822. • A process exit status is saved to be reported back to the parent
  5823. process via ‘wait’ or ‘waitpid’; see *note Process Completion::.
  5824. If the program exited, this status includes as its low-order 8 bits
  5825. the program exit status.
  5826. • Any child processes of the process being terminated are assigned a
  5827. new parent process. (On most systems, including GNU, this is the
  5828. ‘init’ process, with process ID 1.)
  5829. • A ‘SIGCHLD’ signal is sent to the parent process.
  5830. • If the process is a session leader that has a controlling terminal,
  5831. then a ‘SIGHUP’ signal is sent to each process in the foreground
  5832. job, and the controlling terminal is disassociated from that
  5833. session. *Note Job Control::.
  5834. • If termination of a process causes a process group to become
  5835. orphaned, and any member of that process group is stopped, then a
  5836. ‘SIGHUP’ signal and a ‘SIGCONT’ signal are sent to each process in
  5837. the group. *Note Job Control::.
  5838. 
  5839. File: libc.info, Node: Processes, Next: Inter-Process Communication, Prev: Program Basics, Up: Top
  5840. 26 Processes
  5841. ************
  5842. “Processes” are the primitive units for allocation of system resources.
  5843. Each process has its own address space and (usually) one thread of
  5844. control. A process executes a program; you can have multiple processes
  5845. executing the same program, but each process has its own copy of the
  5846. program within its own address space and executes it independently of
  5847. the other copies.
  5848. Processes are organized hierarchically. Each process has a “parent
  5849. process” which explicitly arranged to create it. The processes created
  5850. by a given parent are called its “child processes”. A child inherits
  5851. many of its attributes from the parent process.
  5852. This chapter describes how a program can create, terminate, and
  5853. control child processes. Actually, there are three distinct operations
  5854. involved: creating a new child process, causing the new process to
  5855. execute a program, and coordinating the completion of the child process
  5856. with the original program.
  5857. The ‘system’ function provides a simple, portable mechanism for
  5858. running another program; it does all three steps automatically. If you
  5859. need more control over the details of how this is done, you can use the
  5860. primitive functions to do each step individually instead.
  5861. * Menu:
  5862. * Running a Command:: The easy way to run another program.
  5863. * Process Creation Concepts:: An overview of the hard way to do it.
  5864. * Process Identification:: How to get the process ID of a process.
  5865. * Creating a Process:: How to fork a child process.
  5866. * Executing a File:: How to make a process execute another program.
  5867. * Process Completion:: How to tell when a child process has completed.
  5868. * Process Completion Status:: How to interpret the status value
  5869. returned from a child process.
  5870. * BSD Wait Functions:: More functions, for backward compatibility.
  5871. * Process Creation Example:: A complete example program.
  5872. 
  5873. File: libc.info, Node: Running a Command, Next: Process Creation Concepts, Up: Processes
  5874. 26.1 Running a Command
  5875. ======================
  5876. The easy way to run another program is to use the ‘system’ function.
  5877. This function does all the work of running a subprogram, but it doesn’t
  5878. give you much control over the details: you have to wait until the
  5879. subprogram terminates before you can do anything else.
  5880. -- Function: int system (const char *COMMAND)
  5881. Preliminary: | MT-Safe | AS-Unsafe plugin heap lock | AC-Unsafe
  5882. lock mem | *Note POSIX Safety Concepts::.
  5883. This function executes COMMAND as a shell command. In the GNU C
  5884. Library, it always uses the default shell ‘sh’ to run the command.
  5885. In particular, it searches the directories in ‘PATH’ to find
  5886. programs to execute. The return value is ‘-1’ if it wasn’t
  5887. possible to create the shell process, and otherwise is the status
  5888. of the shell process. *Note Process Completion::, for details on
  5889. how this status code can be interpreted.
  5890. If the COMMAND argument is a null pointer, a return value of zero
  5891. indicates that no command processor is available.
  5892. This function is a cancellation point in multi-threaded programs.
  5893. This is a problem if the thread allocates some resources (like
  5894. memory, file descriptors, semaphores or whatever) at the time
  5895. ‘system’ is called. If the thread gets canceled these resources
  5896. stay allocated until the program ends. To avoid this calls to
  5897. ‘system’ should be protected using cancellation handlers.
  5898. The ‘system’ function is declared in the header file ‘stdlib.h’.
  5899. *Portability Note:* Some C implementations may not have any notion of
  5900. a command processor that can execute other programs. You can determine
  5901. whether a command processor exists by executing ‘system (NULL)’; if the
  5902. return value is nonzero, a command processor is available.
  5903. The ‘popen’ and ‘pclose’ functions (*note Pipe to a Subprocess::) are
  5904. closely related to the ‘system’ function. They allow the parent process
  5905. to communicate with the standard input and output channels of the
  5906. command being executed.
  5907. 
  5908. File: libc.info, Node: Process Creation Concepts, Next: Process Identification, Prev: Running a Command, Up: Processes
  5909. 26.2 Process Creation Concepts
  5910. ==============================
  5911. This section gives an overview of processes and of the steps involved in
  5912. creating a process and making it run another program.
  5913. A new processes is created when one of the functions ‘posix_spawn’,
  5914. ‘fork’, or ‘vfork’ is called. (The ‘system’ and ‘popen’ also create new
  5915. processes internally.) Due to the name of the ‘fork’ function, the act
  5916. of creating a new process is sometimes called “forking” a process. Each
  5917. new process (the “child process” or “subprocess”) is allocated a process
  5918. ID, distinct from the process ID of the parent process. *Note Process
  5919. Identification::.
  5920. After forking a child process, both the parent and child processes
  5921. continue to execute normally. If you want your program to wait for a
  5922. child process to finish executing before continuing, you must do this
  5923. explicitly after the fork operation, by calling ‘wait’ or ‘waitpid’
  5924. (*note Process Completion::). These functions give you limited
  5925. information about why the child terminated—for example, its exit status
  5926. code.
  5927. A newly forked child process continues to execute the same program as
  5928. its parent process, at the point where the ‘fork’ call returns. You can
  5929. use the return value from ‘fork’ to tell whether the program is running
  5930. in the parent process or the child.
  5931. Having several processes run the same program is only occasionally
  5932. useful. But the child can execute another program using one of the
  5933. ‘exec’ functions; see *note Executing a File::. The program that the
  5934. process is executing is called its “process image”. Starting execution
  5935. of a new program causes the process to forget all about its previous
  5936. process image; when the new program exits, the process exits too,
  5937. instead of returning to the previous process image.
  5938. 
  5939. File: libc.info, Node: Process Identification, Next: Creating a Process, Prev: Process Creation Concepts, Up: Processes
  5940. 26.3 Process Identification
  5941. ===========================
  5942. Each process is named by a “process ID” number, a value of type ‘pid_t’.
  5943. A process ID is allocated to each process when it is created. Process
  5944. IDs are reused over time. The lifetime of a process ends when the
  5945. parent process of the corresponding process waits on the process ID
  5946. after the process has terminated. *Note Process Completion::. (The
  5947. parent process can arrange for such waiting to happen implicitly.) A
  5948. process ID uniquely identifies a process only during the lifetime of the
  5949. process. As a rule of thumb, this means that the process must still be
  5950. running.
  5951. Process IDs can also denote process groups and sessions. *Note Job
  5952. Control::.
  5953. On Linux, threads created by ‘pthread_create’ also receive a “thread
  5954. ID”. The thread ID of the initial (main) thread is the same as the
  5955. process ID of the entire process. Thread IDs for subsequently created
  5956. threads are distinct. They are allocated from the same numbering space
  5957. as process IDs. Process IDs and thread IDs are sometimes also referred
  5958. to collectively as “task IDs”. In contrast to processes, threads are
  5959. never waited for explicitly, so a thread ID becomes eligible for reuse
  5960. as soon as a thread exits or is canceled. This is true even for
  5961. joinable threads, not just detached threads. Threads are assigned to a
  5962. “thread group”. In the GNU C Library implementation running on Linux,
  5963. the process ID is the thread group ID of all threads in the process.
  5964. You can get the process ID of a process by calling ‘getpid’. The
  5965. function ‘getppid’ returns the process ID of the parent of the current
  5966. process (this is also known as the “parent process ID”). Your program
  5967. should include the header files ‘unistd.h’ and ‘sys/types.h’ to use
  5968. these functions.
  5969. -- Data Type: pid_t
  5970. The ‘pid_t’ data type is a signed integer type which is capable of
  5971. representing a process ID. In the GNU C Library, this is an ‘int’.
  5972. -- Function: pid_t getpid (void)
  5973. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5974. Concepts::.
  5975. The ‘getpid’ function returns the process ID of the current
  5976. process.
  5977. -- Function: pid_t getppid (void)
  5978. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5979. Concepts::.
  5980. The ‘getppid’ function returns the process ID of the parent of the
  5981. current process.
  5982. -- Function: pid_t gettid (void)
  5983. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5984. Concepts::.
  5985. The ‘gettid’ function returns the thread ID of the current thread.
  5986. The returned value is obtained from the Linux kernel and is not
  5987. subject to caching. See the discussion of thread IDs above,
  5988. especially regarding reuse of the IDs of threads which have exited.
  5989. This function is specific to Linux.
  5990. 
  5991. File: libc.info, Node: Creating a Process, Next: Executing a File, Prev: Process Identification, Up: Processes
  5992. 26.4 Creating a Process
  5993. =======================
  5994. The ‘fork’ function is the primitive for creating a process. It is
  5995. declared in the header file ‘unistd.h’.
  5996. -- Function: pid_t fork (void)
  5997. Preliminary: | MT-Safe | AS-Unsafe plugin | AC-Unsafe lock | *Note
  5998. POSIX Safety Concepts::.
  5999. The ‘fork’ function creates a new process.
  6000. If the operation is successful, there are then both parent and
  6001. child processes and both see ‘fork’ return, but with different
  6002. values: it returns a value of ‘0’ in the child process and returns
  6003. the child’s process ID in the parent process.
  6004. If process creation failed, ‘fork’ returns a value of ‘-1’ in the
  6005. parent process. The following ‘errno’ error conditions are defined
  6006. for ‘fork’:
  6007. ‘EAGAIN’
  6008. There aren’t enough system resources to create another
  6009. process, or the user already has too many processes running.
  6010. This means exceeding the ‘RLIMIT_NPROC’ resource limit, which
  6011. can usually be increased; *note Limits on Resources::.
  6012. ‘ENOMEM’
  6013. The process requires more space than the system can supply.
  6014. The specific attributes of the child process that differ from the
  6015. parent process are:
  6016. • The child process has its own unique process ID.
  6017. • The parent process ID of the child process is the process ID of its
  6018. parent process.
  6019. • The child process gets its own copies of the parent process’s open
  6020. file descriptors. Subsequently changing attributes of the file
  6021. descriptors in the parent process won’t affect the file descriptors
  6022. in the child, and vice versa. *Note Control Operations::.
  6023. However, the file position associated with each descriptor is
  6024. shared by both processes; *note File Position::.
  6025. • The elapsed processor times for the child process are set to zero;
  6026. see *note Processor Time::.
  6027. • The child doesn’t inherit file locks set by the parent process.
  6028. *Note Control Operations::.
  6029. • The child doesn’t inherit alarms set by the parent process. *Note
  6030. Setting an Alarm::.
  6031. • The set of pending signals (*note Delivery of Signal::) for the
  6032. child process is cleared. (The child process inherits its mask of
  6033. blocked signals and signal actions from the parent process.)
  6034. -- Function: pid_t vfork (void)
  6035. Preliminary: | MT-Safe | AS-Unsafe plugin | AC-Unsafe lock | *Note
  6036. POSIX Safety Concepts::.
  6037. The ‘vfork’ function is similar to ‘fork’ but on some systems it is
  6038. more efficient; however, there are restrictions you must follow to
  6039. use it safely.
  6040. While ‘fork’ makes a complete copy of the calling process’s address
  6041. space and allows both the parent and child to execute
  6042. independently, ‘vfork’ does not make this copy. Instead, the child
  6043. process created with ‘vfork’ shares its parent’s address space
  6044. until it calls ‘_exit’ or one of the ‘exec’ functions. In the
  6045. meantime, the parent process suspends execution.
  6046. You must be very careful not to allow the child process created
  6047. with ‘vfork’ to modify any global data or even local variables
  6048. shared with the parent. Furthermore, the child process cannot
  6049. return from (or do a long jump out of) the function that called
  6050. ‘vfork’! This would leave the parent process’s control information
  6051. very confused. If in doubt, use ‘fork’ instead.
  6052. Some operating systems don’t really implement ‘vfork’. The GNU C
  6053. Library permits you to use ‘vfork’ on all systems, but actually
  6054. executes ‘fork’ if ‘vfork’ isn’t available. If you follow the
  6055. proper precautions for using ‘vfork’, your program will still work
  6056. even if the system uses ‘fork’ instead.
  6057. 
  6058. File: libc.info, Node: Executing a File, Next: Process Completion, Prev: Creating a Process, Up: Processes
  6059. 26.5 Executing a File
  6060. =====================
  6061. This section describes the ‘exec’ family of functions, for executing a
  6062. file as a process image. You can use these functions to make a child
  6063. process execute a new program after it has been forked.
  6064. To see the effects of ‘exec’ from the point of view of the called
  6065. program, see *note Program Basics::.
  6066. The functions in this family differ in how you specify the arguments,
  6067. but otherwise they all do the same thing. They are declared in the
  6068. header file ‘unistd.h’.
  6069. -- Function: int execv (const char *FILENAME, char *const ARGV[])
  6070. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6071. Concepts::.
  6072. The ‘execv’ function executes the file named by FILENAME as a new
  6073. process image.
  6074. The ARGV argument is an array of null-terminated strings that is
  6075. used to provide a value for the ‘argv’ argument to the ‘main’
  6076. function of the program to be executed. The last element of this
  6077. array must be a null pointer. By convention, the first element of
  6078. this array is the file name of the program sans directory names.
  6079. *Note Program Arguments::, for full details on how programs can
  6080. access these arguments.
  6081. The environment for the new process image is taken from the
  6082. ‘environ’ variable of the current process image; see *note
  6083. Environment Variables::, for information about environments.
  6084. -- Function: int execl (const char *FILENAME, const char *ARG0, ...)
  6085. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  6086. POSIX Safety Concepts::.
  6087. This is similar to ‘execv’, but the ARGV strings are specified
  6088. individually instead of as an array. A null pointer must be passed
  6089. as the last such argument.
  6090. -- Function: int execve (const char *FILENAME, char *const ARGV[], char
  6091. *const ENV[])
  6092. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6093. Concepts::.
  6094. This is similar to ‘execv’, but permits you to specify the
  6095. environment for the new program explicitly as the ENV argument.
  6096. This should be an array of strings in the same format as for the
  6097. ‘environ’ variable; see *note Environment Access::.
  6098. -- Function: int fexecve (int FD, char *const ARGV[], char *const
  6099. ENV[])
  6100. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6101. Concepts::.
  6102. This is similar to ‘execve’, but instead of identifying the program
  6103. executable by its pathname, the file descriptor FD is used. The
  6104. descriptor must have been opened with the ‘O_RDONLY’ flag or (on
  6105. Linux) the ‘O_PATH’ flag.
  6106. On Linux, ‘fexecve’ can fail with an error of ‘ENOSYS’ if ‘/proc’
  6107. has not been mounted and the kernel lacks support for the
  6108. underlying ‘execveat’ system call.
  6109. -- Function: int execle (const char *FILENAME, const char *ARG0, ...,
  6110. char *const ENV[])
  6111. Preliminary: | MT-Safe | AS-Unsafe heap | AC-Unsafe mem | *Note
  6112. POSIX Safety Concepts::.
  6113. This is similar to ‘execl’, but permits you to specify the
  6114. environment for the new program explicitly. The environment
  6115. argument is passed following the null pointer that marks the last
  6116. ARGV argument, and should be an array of strings in the same format
  6117. as for the ‘environ’ variable.
  6118. -- Function: int execvp (const char *FILENAME, char *const ARGV[])
  6119. Preliminary: | MT-Safe env | AS-Unsafe heap | AC-Unsafe mem | *Note
  6120. POSIX Safety Concepts::.
  6121. The ‘execvp’ function is similar to ‘execv’, except that it
  6122. searches the directories listed in the ‘PATH’ environment variable
  6123. (*note Standard Environment::) to find the full file name of a file
  6124. from FILENAME if FILENAME does not contain a slash.
  6125. This function is useful for executing system utility programs,
  6126. because it looks for them in the places that the user has chosen.
  6127. Shells use it to run the commands that users type.
  6128. -- Function: int execlp (const char *FILENAME, const char *ARG0, ...)
  6129. Preliminary: | MT-Safe env | AS-Unsafe heap | AC-Unsafe mem | *Note
  6130. POSIX Safety Concepts::.
  6131. This function is like ‘execl’, except that it performs the same
  6132. file name searching as the ‘execvp’ function.
  6133. The size of the argument list and environment list taken together
  6134. must not be greater than ‘ARG_MAX’ bytes. *Note General Limits::. On
  6135. GNU/Hurd systems, the size (which compares against ‘ARG_MAX’) includes,
  6136. for each string, the number of characters in the string, plus the size
  6137. of a ‘char *’, plus one, rounded up to a multiple of the size of a ‘char
  6138. *’. Other systems may have somewhat different rules for counting.
  6139. These functions normally don’t return, since execution of a new
  6140. program causes the currently executing program to go away completely. A
  6141. value of ‘-1’ is returned in the event of a failure. In addition to the
  6142. usual file name errors (*note File Name Errors::), the following ‘errno’
  6143. error conditions are defined for these functions:
  6144. ‘E2BIG’
  6145. The combined size of the new program’s argument list and
  6146. environment list is larger than ‘ARG_MAX’ bytes. GNU/Hurd systems
  6147. have no specific limit on the argument list size, so this error
  6148. code cannot result, but you may get ‘ENOMEM’ instead if the
  6149. arguments are too big for available memory.
  6150. ‘ENOEXEC’
  6151. The specified file can’t be executed because it isn’t in the right
  6152. format.
  6153. ‘ENOMEM’
  6154. Executing the specified file requires more storage than is
  6155. available.
  6156. If execution of the new file succeeds, it updates the access time
  6157. field of the file as if the file had been read. *Note File Times::, for
  6158. more details about access times of files.
  6159. The point at which the file is closed again is not specified, but is
  6160. at some point before the process exits or before another process image
  6161. is executed.
  6162. Executing a new process image completely changes the contents of
  6163. memory, copying only the argument and environment strings to new
  6164. locations. But many other attributes of the process are unchanged:
  6165. • The process ID and the parent process ID. *Note Process Creation
  6166. Concepts::.
  6167. • Session and process group membership. *Note Concepts of Job
  6168. Control::.
  6169. • Real user ID and group ID, and supplementary group IDs. *Note
  6170. Process Persona::.
  6171. • Pending alarms. *Note Setting an Alarm::.
  6172. • Current working directory and root directory. *Note Working
  6173. Directory::. On GNU/Hurd systems, the root directory is not copied
  6174. when executing a setuid program; instead the system default root
  6175. directory is used for the new program.
  6176. • File mode creation mask. *Note Setting Permissions::.
  6177. • Process signal mask; see *note Process Signal Mask::.
  6178. • Pending signals; see *note Blocking Signals::.
  6179. • Elapsed processor time associated with the process; see *note
  6180. Processor Time::.
  6181. If the set-user-ID and set-group-ID mode bits of the process image
  6182. file are set, this affects the effective user ID and effective group ID
  6183. (respectively) of the process. These concepts are discussed in detail
  6184. in *note Process Persona::.
  6185. Signals that are set to be ignored in the existing process image are
  6186. also set to be ignored in the new process image. All other signals are
  6187. set to the default action in the new process image. For more
  6188. information about signals, see *note Signal Handling::.
  6189. File descriptors open in the existing process image remain open in
  6190. the new process image, unless they have the ‘FD_CLOEXEC’ (close-on-exec)
  6191. flag set. The files that remain open inherit all attributes of the open
  6192. file descriptors from the existing process image, including file locks.
  6193. File descriptors are discussed in *note Low-Level I/O::.
  6194. Streams, by contrast, cannot survive through ‘exec’ functions,
  6195. because they are located in the memory of the process itself. The new
  6196. process image has no streams except those it creates afresh. Each of
  6197. the streams in the pre-‘exec’ process image has a descriptor inside it,
  6198. and these descriptors do survive through ‘exec’ (provided that they do
  6199. not have ‘FD_CLOEXEC’ set). The new process image can reconnect these
  6200. to new streams using ‘fdopen’ (*note Descriptors and Streams::).
  6201. 
  6202. File: libc.info, Node: Process Completion, Next: Process Completion Status, Prev: Executing a File, Up: Processes
  6203. 26.6 Process Completion
  6204. =======================
  6205. The functions described in this section are used to wait for a child
  6206. process to terminate or stop, and determine its status. These functions
  6207. are declared in the header file ‘sys/wait.h’.
  6208. -- Function: pid_t waitpid (pid_t PID, int *STATUS-PTR, int OPTIONS)
  6209. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6210. Concepts::.
  6211. The ‘waitpid’ function is used to request status information from a
  6212. child process whose process ID is PID. Normally, the calling
  6213. process is suspended until the child process makes status
  6214. information available by terminating.
  6215. Other values for the PID argument have special interpretations. A
  6216. value of ‘-1’ or ‘WAIT_ANY’ requests status information for any
  6217. child process; a value of ‘0’ or ‘WAIT_MYPGRP’ requests information
  6218. for any child process in the same process group as the calling
  6219. process; and any other negative value − PGID requests information
  6220. for any child process whose process group ID is PGID.
  6221. If status information for a child process is available immediately,
  6222. this function returns immediately without waiting. If more than
  6223. one eligible child process has status information available, one of
  6224. them is chosen randomly, and its status is returned immediately.
  6225. To get the status from the other eligible child processes, you need
  6226. to call ‘waitpid’ again.
  6227. The OPTIONS argument is a bit mask. Its value should be the
  6228. bitwise OR (that is, the ‘|’ operator) of zero or more of the
  6229. ‘WNOHANG’ and ‘WUNTRACED’ flags. You can use the ‘WNOHANG’ flag to
  6230. indicate that the parent process shouldn’t wait; and the
  6231. ‘WUNTRACED’ flag to request status information from stopped
  6232. processes as well as processes that have terminated.
  6233. The status information from the child process is stored in the
  6234. object that STATUS-PTR points to, unless STATUS-PTR is a null
  6235. pointer.
  6236. This function is a cancellation point in multi-threaded programs.
  6237. This is a problem if the thread allocates some resources (like
  6238. memory, file descriptors, semaphores or whatever) at the time
  6239. ‘waitpid’ is called. If the thread gets canceled these resources
  6240. stay allocated until the program ends. To avoid this calls to
  6241. ‘waitpid’ should be protected using cancellation handlers.
  6242. The return value is normally the process ID of the child process
  6243. whose status is reported. If there are child processes but none of
  6244. them is waiting to be noticed, ‘waitpid’ will block until one is.
  6245. However, if the ‘WNOHANG’ option was specified, ‘waitpid’ will
  6246. return zero instead of blocking.
  6247. If a specific PID to wait for was given to ‘waitpid’, it will
  6248. ignore all other children (if any). Therefore if there are
  6249. children waiting to be noticed but the child whose PID was
  6250. specified is not one of them, ‘waitpid’ will block or return zero
  6251. as described above.
  6252. A value of ‘-1’ is returned in case of error. The following
  6253. ‘errno’ error conditions are defined for this function:
  6254. ‘EINTR’
  6255. The function was interrupted by delivery of a signal to the
  6256. calling process. *Note Interrupted Primitives::.
  6257. ‘ECHILD’
  6258. There are no child processes to wait for, or the specified PID
  6259. is not a child of the calling process.
  6260. ‘EINVAL’
  6261. An invalid value was provided for the OPTIONS argument.
  6262. These symbolic constants are defined as values for the PID argument
  6263. to the ‘waitpid’ function.
  6264. ‘WAIT_ANY’
  6265. This constant macro (whose value is ‘-1’) specifies that ‘waitpid’
  6266. should return status information about any child process.
  6267. ‘WAIT_MYPGRP’
  6268. This constant (with value ‘0’) specifies that ‘waitpid’ should
  6269. return status information about any child process in the same
  6270. process group as the calling process.
  6271. These symbolic constants are defined as flags for the OPTIONS
  6272. argument to the ‘waitpid’ function. You can bitwise-OR the flags
  6273. together to obtain a value to use as the argument.
  6274. ‘WNOHANG’
  6275. This flag specifies that ‘waitpid’ should return immediately
  6276. instead of waiting, if there is no child process ready to be
  6277. noticed.
  6278. ‘WUNTRACED’
  6279. This flag specifies that ‘waitpid’ should report the status of any
  6280. child processes that have been stopped as well as those that have
  6281. terminated.
  6282. -- Function: pid_t wait (int *STATUS-PTR)
  6283. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6284. Concepts::.
  6285. This is a simplified version of ‘waitpid’, and is used to wait
  6286. until any one child process terminates. The call:
  6287. wait (&status)
  6288. is exactly equivalent to:
  6289. waitpid (-1, &status, 0)
  6290. This function is a cancellation point in multi-threaded programs.
  6291. This is a problem if the thread allocates some resources (like
  6292. memory, file descriptors, semaphores or whatever) at the time
  6293. ‘wait’ is called. If the thread gets canceled these resources stay
  6294. allocated until the program ends. To avoid this calls to ‘wait’
  6295. should be protected using cancellation handlers.
  6296. -- Function: pid_t wait4 (pid_t PID, int *STATUS-PTR, int OPTIONS,
  6297. struct rusage *USAGE)
  6298. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6299. Concepts::.
  6300. If USAGE is a null pointer, ‘wait4’ is equivalent to ‘waitpid (PID,
  6301. STATUS-PTR, OPTIONS)’.
  6302. If USAGE is not null, ‘wait4’ stores usage figures for the child
  6303. process in ‘*RUSAGE’ (but only if the child has terminated, not if
  6304. it has stopped). *Note Resource Usage::.
  6305. This function is a BSD extension.
  6306. Here’s an example of how to use ‘waitpid’ to get the status from all
  6307. child processes that have terminated, without ever waiting. This
  6308. function is designed to be a handler for ‘SIGCHLD’, the signal that
  6309. indicates that at least one child process has terminated.
  6310. void
  6311. sigchld_handler (int signum)
  6312. {
  6313. int pid, status, serrno;
  6314. serrno = errno;
  6315. while (1)
  6316. {
  6317. pid = waitpid (WAIT_ANY, &status, WNOHANG);
  6318. if (pid < 0)
  6319. {
  6320. perror ("waitpid");
  6321. break;
  6322. }
  6323. if (pid == 0)
  6324. break;
  6325. notice_termination (pid, status);
  6326. }
  6327. errno = serrno;
  6328. }