libc.info-12 287 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337
  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: Process Completion Status, Next: BSD Wait Functions, Prev: Process Completion, Up: Processes
  2099. 26.7 Process Completion Status
  2100. ==============================
  2101. If the exit status value (*note Program Termination::) of the child
  2102. process is zero, then the status value reported by ‘waitpid’ or ‘wait’
  2103. is also zero. You can test for other kinds of information encoded in
  2104. the returned status value using the following macros. These macros are
  2105. defined in the header file ‘sys/wait.h’.
  2106. -- Macro: int WIFEXITED (int STATUS)
  2107. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2108. Concepts::.
  2109. This macro returns a nonzero value if the child process terminated
  2110. normally with ‘exit’ or ‘_exit’.
  2111. -- Macro: int WEXITSTATUS (int STATUS)
  2112. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2113. Concepts::.
  2114. If ‘WIFEXITED’ is true of STATUS, this macro returns the low-order
  2115. 8 bits of the exit status value from the child process. *Note Exit
  2116. Status::.
  2117. -- Macro: int WIFSIGNALED (int STATUS)
  2118. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2119. Concepts::.
  2120. This macro returns a nonzero value if the child process terminated
  2121. because it received a signal that was not handled. *Note Signal
  2122. Handling::.
  2123. -- Macro: int WTERMSIG (int STATUS)
  2124. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2125. Concepts::.
  2126. If ‘WIFSIGNALED’ is true of STATUS, this macro returns the signal
  2127. number of the signal that terminated the child process.
  2128. -- Macro: int WCOREDUMP (int STATUS)
  2129. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2130. Concepts::.
  2131. This macro returns a nonzero value if the child process terminated
  2132. and produced a core dump.
  2133. -- Macro: int WIFSTOPPED (int STATUS)
  2134. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2135. Concepts::.
  2136. This macro returns a nonzero value if the child process is stopped.
  2137. -- Macro: int WSTOPSIG (int STATUS)
  2138. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2139. Concepts::.
  2140. If ‘WIFSTOPPED’ is true of STATUS, this macro returns the signal
  2141. number of the signal that caused the child process to stop.
  2142. 
  2143. File: libc.info, Node: BSD Wait Functions, Next: Process Creation Example, Prev: Process Completion Status, Up: Processes
  2144. 26.8 BSD Process Wait Function
  2145. ==============================
  2146. The GNU C Library also provides the ‘wait3’ function for compatibility
  2147. with BSD. This function is declared in ‘sys/wait.h’. It is the
  2148. predecessor to ‘wait4’, which is more flexible. ‘wait3’ is now
  2149. obsolete.
  2150. -- Function: pid_t wait3 (int *STATUS-PTR, int OPTIONS, struct rusage
  2151. *USAGE)
  2152. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2153. Concepts::.
  2154. If USAGE is a null pointer, ‘wait3’ is equivalent to ‘waitpid (-1,
  2155. STATUS-PTR, OPTIONS)’.
  2156. If USAGE is not null, ‘wait3’ stores usage figures for the child
  2157. process in ‘*RUSAGE’ (but only if the child has terminated, not if
  2158. it has stopped). *Note Resource Usage::.
  2159. 
  2160. File: libc.info, Node: Process Creation Example, Prev: BSD Wait Functions, Up: Processes
  2161. 26.9 Process Creation Example
  2162. =============================
  2163. Here is an example program showing how you might write a function
  2164. similar to the built-in ‘system’. It executes its COMMAND argument
  2165. using the equivalent of ‘sh -c COMMAND’.
  2166. #include <stddef.h>
  2167. #include <stdlib.h>
  2168. #include <unistd.h>
  2169. #include <sys/types.h>
  2170. #include <sys/wait.h>
  2171. /* Execute the command using this shell program. */
  2172. #define SHELL "/bin/sh"
  2173. int
  2174. my_system (const char *command)
  2175. {
  2176. int status;
  2177. pid_t pid;
  2178. pid = fork ();
  2179. if (pid == 0)
  2180. {
  2181. /* This is the child process. Execute the shell command. */
  2182. execl (SHELL, SHELL, "-c", command, NULL);
  2183. _exit (EXIT_FAILURE);
  2184. }
  2185. else if (pid < 0)
  2186. /* The fork failed. Report failure. */
  2187. status = -1;
  2188. else
  2189. /* This is the parent process. Wait for the child to complete. */
  2190. if (waitpid (pid, &status, 0) != pid)
  2191. status = -1;
  2192. return status;
  2193. }
  2194. There are a couple of things you should pay attention to in this
  2195. example.
  2196. Remember that the first ‘argv’ argument supplied to the program
  2197. represents the name of the program being executed. That is why, in the
  2198. call to ‘execl’, ‘SHELL’ is supplied once to name the program to execute
  2199. and a second time to supply a value for ‘argv[0]’.
  2200. The ‘execl’ call in the child process doesn’t return if it is
  2201. successful. If it fails, you must do something to make the child
  2202. process terminate. Just returning a bad status code with ‘return’ would
  2203. leave two processes running the original program. Instead, the right
  2204. behavior is for the child process to report failure to its parent
  2205. process.
  2206. Call ‘_exit’ to accomplish this. The reason for using ‘_exit’
  2207. instead of ‘exit’ is to avoid flushing fully buffered streams such as
  2208. ‘stdout’. The buffers of these streams probably contain data that was
  2209. copied from the parent process by the ‘fork’, data that will be output
  2210. eventually by the parent process. Calling ‘exit’ in the child would
  2211. output the data twice. *Note Termination Internals::.
  2212. 
  2213. File: libc.info, Node: Inter-Process Communication, Next: Job Control, Prev: Processes, Up: Top
  2214. 27 Inter-Process Communication
  2215. ******************************
  2216. This chapter describes the GNU C Library inter-process communication
  2217. primitives.
  2218. * Menu:
  2219. * Semaphores:: Support for creating and managing semaphores
  2220. 
  2221. File: libc.info, Node: Semaphores, Up: Inter-Process Communication
  2222. 27.1 Semaphores
  2223. ===============
  2224. The GNU C Library implements the semaphore APIs as defined in POSIX and
  2225. System V. Semaphores can be used by multiple processes to coordinate
  2226. shared resources. The following is a complete list of the semaphore
  2227. functions provided by the GNU C Library.
  2228. 27.1.1 System V Semaphores
  2229. --------------------------
  2230. -- Function: int semctl (int SEMID, int SEMNUM, int CMD);
  2231. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt/linux | *Note
  2232. POSIX Safety Concepts::.
  2233. -- Function: int semget (key_t KEY, int NSEMS, int SEMFLG);
  2234. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2235. Concepts::.
  2236. -- Function: int semop (int SEMID, struct sembuf *SOPS, size_t NSOPS);
  2237. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2238. Concepts::.
  2239. -- Function: int semtimedop (int SEMID, struct sembuf *SOPS, size_t
  2240. NSOPS, const struct timespec *TIMEOUT);
  2241. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2242. Concepts::.
  2243. 27.1.2 POSIX Semaphores
  2244. -----------------------
  2245. -- Function: int sem_init (sem_t *SEM, int PSHARED, unsigned int
  2246. VALUE);
  2247. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  2248. Safety Concepts::.
  2249. -- Function: int sem_destroy (sem_t *SEM);
  2250. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2251. Concepts::.
  2252. -- Function: sem_t *sem_open (const char *NAME, int OFLAG, ...);
  2253. Preliminary: | MT-Safe | AS-Unsafe init | AC-Unsafe init | *Note
  2254. POSIX Safety Concepts::.
  2255. -- Function: int sem_close (sem_t *SEM);
  2256. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  2257. POSIX Safety Concepts::.
  2258. -- Function: int sem_unlink (const char *NAME);
  2259. Preliminary: | MT-Safe | AS-Unsafe init | AC-Unsafe corrupt | *Note
  2260. POSIX Safety Concepts::.
  2261. -- Function: int sem_wait (sem_t *SEM);
  2262. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  2263. Safety Concepts::.
  2264. -- Function: int sem_timedwait (sem_t *SEM, const struct timespec
  2265. *ABSTIME);
  2266. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  2267. Safety Concepts::.
  2268. -- Function: int sem_trywait (sem_t *SEM);
  2269. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2270. Concepts::.
  2271. -- Function: int sem_post (sem_t *SEM);
  2272. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2273. Concepts::.
  2274. -- Function: int sem_getvalue (sem_t *SEM, int *SVAL);
  2275. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2276. Concepts::.
  2277. 
  2278. File: libc.info, Node: Job Control, Next: Name Service Switch, Prev: Inter-Process Communication, Up: Top
  2279. 28 Job Control
  2280. **************
  2281. “Job control” refers to the protocol for allowing a user to move between
  2282. multiple “process groups” (or “jobs”) within a single “login session”.
  2283. The job control facilities are set up so that appropriate behavior for
  2284. most programs happens automatically and they need not do anything
  2285. special about job control. So you can probably ignore the material in
  2286. this chapter unless you are writing a shell or login program.
  2287. You need to be familiar with concepts relating to process creation
  2288. (*note Process Creation Concepts::) and signal handling (*note Signal
  2289. Handling::) in order to understand this material presented in this
  2290. chapter.
  2291. Some old systems do not support job control, but GNU systems always
  2292. have, and it is a required feature in the 2001 revision of POSIX.1
  2293. (*note POSIX::). If you need to be portable to old systems, you can use
  2294. the ‘_POSIX_JOB_CONTROL’ macro to test at compile-time whether the
  2295. system supports job control. *Note System Options::.
  2296. * Menu:
  2297. * Concepts of Job Control:: Jobs can be controlled by a shell.
  2298. * Controlling Terminal:: How a process gets its controlling terminal.
  2299. * Access to the Terminal:: How processes share the controlling terminal.
  2300. * Orphaned Process Groups:: Jobs left after the user logs out.
  2301. * Implementing a Shell:: What a shell must do to implement job control.
  2302. * Functions for Job Control:: Functions to control process groups.
  2303. 
  2304. File: libc.info, Node: Concepts of Job Control, Next: Controlling Terminal, Up: Job Control
  2305. 28.1 Concepts of Job Control
  2306. ============================
  2307. The fundamental purpose of an interactive shell is to read commands from
  2308. the user’s terminal and create processes to execute the programs
  2309. specified by those commands. It can do this using the ‘fork’ (*note
  2310. Creating a Process::) and ‘exec’ (*note Executing a File::) functions.
  2311. A single command may run just one process—but often one command uses
  2312. several processes. If you use the ‘|’ operator in a shell command, you
  2313. explicitly request several programs in their own processes. But even if
  2314. you run just one program, it can use multiple processes internally. For
  2315. example, a single compilation command such as ‘cc -c foo.c’ typically
  2316. uses four processes (though normally only two at any given time). If
  2317. you run ‘make’, its job is to run other programs in separate processes.
  2318. The processes belonging to a single command are called a “process
  2319. group” or “job”. This is so that you can operate on all of them at
  2320. once. For example, typing ‘C-c’ sends the signal ‘SIGINT’ to terminate
  2321. all the processes in the foreground process group.
  2322. A “session” is a larger group of processes. Normally all the
  2323. processes that stem from a single login belong to the same session.
  2324. Every process belongs to a process group. When a process is created,
  2325. it becomes a member of the same process group and session as its parent
  2326. process. You can put it in another process group using the ‘setpgid’
  2327. function, provided the process group belongs to the same session.
  2328. The only way to put a process in a different session is to make it
  2329. the initial process of a new session, or a “session leader”, using the
  2330. ‘setsid’ function. This also puts the session leader into a new process
  2331. group, and you can’t move it out of that process group again.
  2332. Usually, new sessions are created by the system login program, and
  2333. the session leader is the process running the user’s login shell.
  2334. A shell that supports job control must arrange to control which job
  2335. can use the terminal at any time. Otherwise there might be multiple
  2336. jobs trying to read from the terminal at once, and confusion about which
  2337. process should receive the input typed by the user. To prevent this,
  2338. the shell must cooperate with the terminal driver using the protocol
  2339. described in this chapter.
  2340. The shell can give unlimited access to the controlling terminal to
  2341. only one process group at a time. This is called the “foreground job”
  2342. on that controlling terminal. Other process groups managed by the shell
  2343. that are executing without such access to the terminal are called
  2344. “background jobs”.
  2345. If a background job needs to read from its controlling terminal, it
  2346. is “stopped” by the terminal driver; if the ‘TOSTOP’ mode is set,
  2347. likewise for writing. The user can stop a foreground job by typing the
  2348. SUSP character (*note Special Characters::) and a program can stop any
  2349. job by sending it a ‘SIGSTOP’ signal. It’s the responsibility of the
  2350. shell to notice when jobs stop, to notify the user about them, and to
  2351. provide mechanisms for allowing the user to interactively continue
  2352. stopped jobs and switch jobs between foreground and background.
  2353. *Note Access to the Terminal::, for more information about I/O to the
  2354. controlling terminal.
  2355. 
  2356. File: libc.info, Node: Controlling Terminal, Next: Access to the Terminal, Prev: Concepts of Job Control, Up: Job Control
  2357. 28.2 Controlling Terminal of a Process
  2358. ======================================
  2359. One of the attributes of a process is its controlling terminal. Child
  2360. processes created with ‘fork’ inherit the controlling terminal from
  2361. their parent process. In this way, all the processes in a session
  2362. inherit the controlling terminal from the session leader. A session
  2363. leader that has control of a terminal is called the “controlling
  2364. process” of that terminal.
  2365. You generally do not need to worry about the exact mechanism used to
  2366. allocate a controlling terminal to a session, since it is done for you
  2367. by the system when you log in.
  2368. An individual process disconnects from its controlling terminal when
  2369. it calls ‘setsid’ to become the leader of a new session. *Note Process
  2370. Group Functions::.
  2371. 
  2372. File: libc.info, Node: Access to the Terminal, Next: Orphaned Process Groups, Prev: Controlling Terminal, Up: Job Control
  2373. 28.3 Access to the Controlling Terminal
  2374. =======================================
  2375. Processes in the foreground job of a controlling terminal have
  2376. unrestricted access to that terminal; background processes do not. This
  2377. section describes in more detail what happens when a process in a
  2378. background job tries to access its controlling terminal.
  2379. When a process in a background job tries to read from its controlling
  2380. terminal, the process group is usually sent a ‘SIGTTIN’ signal. This
  2381. normally causes all of the processes in that group to stop (unless they
  2382. handle the signal and don’t stop themselves). However, if the reading
  2383. process is ignoring or blocking this signal, then ‘read’ fails with an
  2384. ‘EIO’ error instead.
  2385. Similarly, when a process in a background job tries to write to its
  2386. controlling terminal, the default behavior is to send a ‘SIGTTOU’ signal
  2387. to the process group. However, the behavior is modified by the ‘TOSTOP’
  2388. bit of the local modes flags (*note Local Modes::). If this bit is not
  2389. set (which is the default), then writing to the controlling terminal is
  2390. always permitted without sending a signal. Writing is also permitted if
  2391. the ‘SIGTTOU’ signal is being ignored or blocked by the writing process.
  2392. Most other terminal operations that a program can do are treated as
  2393. reading or as writing. (The description of each operation should say
  2394. which.)
  2395. For more information about the primitive ‘read’ and ‘write’
  2396. functions, see *note I/O Primitives::.
  2397. 
  2398. File: libc.info, Node: Orphaned Process Groups, Next: Implementing a Shell, Prev: Access to the Terminal, Up: Job Control
  2399. 28.4 Orphaned Process Groups
  2400. ============================
  2401. When a controlling process terminates, its terminal becomes free and a
  2402. new session can be established on it. (In fact, another user could log
  2403. in on the terminal.) This could cause a problem if any processes from
  2404. the old session are still trying to use that terminal.
  2405. To prevent problems, process groups that continue running even after
  2406. the session leader has terminated are marked as “orphaned process
  2407. groups”.
  2408. When a process group becomes an orphan, its processes are sent a
  2409. ‘SIGHUP’ signal. Ordinarily, this causes the processes to terminate.
  2410. However, if a program ignores this signal or establishes a handler for
  2411. it (*note Signal Handling::), it can continue running as in the orphan
  2412. process group even after its controlling process terminates; but it
  2413. still cannot access the terminal any more.
  2414. 
  2415. File: libc.info, Node: Implementing a Shell, Next: Functions for Job Control, Prev: Orphaned Process Groups, Up: Job Control
  2416. 28.5 Implementing a Job Control Shell
  2417. =====================================
  2418. This section describes what a shell must do to implement job control, by
  2419. presenting an extensive sample program to illustrate the concepts
  2420. involved.
  2421. * Menu:
  2422. * Data Structures:: Introduction to the sample shell.
  2423. * Initializing the Shell:: What the shell must do to take
  2424. responsibility for job control.
  2425. * Launching Jobs:: Creating jobs to execute commands.
  2426. * Foreground and Background:: Putting a job in foreground of background.
  2427. * Stopped and Terminated Jobs:: Reporting job status.
  2428. * Continuing Stopped Jobs:: How to continue a stopped job in
  2429. the foreground or background.
  2430. * Missing Pieces:: Other parts of the shell.
  2431. 
  2432. File: libc.info, Node: Data Structures, Next: Initializing the Shell, Up: Implementing a Shell
  2433. 28.5.1 Data Structures for the Shell
  2434. ------------------------------------
  2435. All of the program examples included in this chapter are part of a
  2436. simple shell program. This section presents data structures and utility
  2437. functions which are used throughout the example.
  2438. The sample shell deals mainly with two data structures. The ‘job’
  2439. type contains information about a job, which is a set of subprocesses
  2440. linked together with pipes. The ‘process’ type holds information about
  2441. a single subprocess. Here are the relevant data structure declarations:
  2442. /* A process is a single process. */
  2443. typedef struct process
  2444. {
  2445. struct process *next; /* next process in pipeline */
  2446. char **argv; /* for exec */
  2447. pid_t pid; /* process ID */
  2448. char completed; /* true if process has completed */
  2449. char stopped; /* true if process has stopped */
  2450. int status; /* reported status value */
  2451. } process;
  2452. /* A job is a pipeline of processes. */
  2453. typedef struct job
  2454. {
  2455. struct job *next; /* next active job */
  2456. char *command; /* command line, used for messages */
  2457. process *first_process; /* list of processes in this job */
  2458. pid_t pgid; /* process group ID */
  2459. char notified; /* true if user told about stopped job */
  2460. struct termios tmodes; /* saved terminal modes */
  2461. int stdin, stdout, stderr; /* standard i/o channels */
  2462. } job;
  2463. /* The active jobs are linked into a list. This is its head. */
  2464. job *first_job = NULL;
  2465. Here are some utility functions that are used for operating on ‘job’
  2466. objects.
  2467. /* Find the active job with the indicated PGID. */
  2468. job *
  2469. find_job (pid_t pgid)
  2470. {
  2471. job *j;
  2472. for (j = first_job; j; j = j->next)
  2473. if (j->pgid == pgid)
  2474. return j;
  2475. return NULL;
  2476. }
  2477. /* Return true if all processes in the job have stopped or completed. */
  2478. int
  2479. job_is_stopped (job *j)
  2480. {
  2481. process *p;
  2482. for (p = j->first_process; p; p = p->next)
  2483. if (!p->completed && !p->stopped)
  2484. return 0;
  2485. return 1;
  2486. }
  2487. /* Return true if all processes in the job have completed. */
  2488. int
  2489. job_is_completed (job *j)
  2490. {
  2491. process *p;
  2492. for (p = j->first_process; p; p = p->next)
  2493. if (!p->completed)
  2494. return 0;
  2495. return 1;
  2496. }
  2497. 
  2498. File: libc.info, Node: Initializing the Shell, Next: Launching Jobs, Prev: Data Structures, Up: Implementing a Shell
  2499. 28.5.2 Initializing the Shell
  2500. -----------------------------
  2501. When a shell program that normally performs job control is started, it
  2502. has to be careful in case it has been invoked from another shell that is
  2503. already doing its own job control.
  2504. A subshell that runs interactively has to ensure that it has been
  2505. placed in the foreground by its parent shell before it can enable job
  2506. control itself. It does this by getting its initial process group ID
  2507. with the ‘getpgrp’ function, and comparing it to the process group ID of
  2508. the current foreground job associated with its controlling terminal
  2509. (which can be retrieved using the ‘tcgetpgrp’ function).
  2510. If the subshell is not running as a foreground job, it must stop
  2511. itself by sending a ‘SIGTTIN’ signal to its own process group. It may
  2512. not arbitrarily put itself into the foreground; it must wait for the
  2513. user to tell the parent shell to do this. If the subshell is continued
  2514. again, it should repeat the check and stop itself again if it is still
  2515. not in the foreground.
  2516. Once the subshell has been placed into the foreground by its parent
  2517. shell, it can enable its own job control. It does this by calling
  2518. ‘setpgid’ to put itself into its own process group, and then calling
  2519. ‘tcsetpgrp’ to place this process group into the foreground.
  2520. When a shell enables job control, it should set itself to ignore all
  2521. the job control stop signals so that it doesn’t accidentally stop
  2522. itself. You can do this by setting the action for all the stop signals
  2523. to ‘SIG_IGN’.
  2524. A subshell that runs non-interactively cannot and should not support
  2525. job control. It must leave all processes it creates in the same process
  2526. group as the shell itself; this allows the non-interactive shell and its
  2527. child processes to be treated as a single job by the parent shell. This
  2528. is easy to do—just don’t use any of the job control primitives—but you
  2529. must remember to make the shell do it.
  2530. Here is the initialization code for the sample shell that shows how
  2531. to do all of this.
  2532. /* Keep track of attributes of the shell. */
  2533. #include <sys/types.h>
  2534. #include <termios.h>
  2535. #include <unistd.h>
  2536. pid_t shell_pgid;
  2537. struct termios shell_tmodes;
  2538. int shell_terminal;
  2539. int shell_is_interactive;
  2540. /* Make sure the shell is running interactively as the foreground job
  2541. before proceeding. */
  2542. void
  2543. init_shell ()
  2544. {
  2545. /* See if we are running interactively. */
  2546. shell_terminal = STDIN_FILENO;
  2547. shell_is_interactive = isatty (shell_terminal);
  2548. if (shell_is_interactive)
  2549. {
  2550. /* Loop until we are in the foreground. */
  2551. while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
  2552. kill (- shell_pgid, SIGTTIN);
  2553. /* Ignore interactive and job-control signals. */
  2554. signal (SIGINT, SIG_IGN);
  2555. signal (SIGQUIT, SIG_IGN);
  2556. signal (SIGTSTP, SIG_IGN);
  2557. signal (SIGTTIN, SIG_IGN);
  2558. signal (SIGTTOU, SIG_IGN);
  2559. signal (SIGCHLD, SIG_IGN);
  2560. /* Put ourselves in our own process group. */
  2561. shell_pgid = getpid ();
  2562. if (setpgid (shell_pgid, shell_pgid) < 0)
  2563. {
  2564. perror ("Couldn't put the shell in its own process group");
  2565. exit (1);
  2566. }
  2567. /* Grab control of the terminal. */
  2568. tcsetpgrp (shell_terminal, shell_pgid);
  2569. /* Save default terminal attributes for shell. */
  2570. tcgetattr (shell_terminal, &shell_tmodes);
  2571. }
  2572. }
  2573. 
  2574. File: libc.info, Node: Launching Jobs, Next: Foreground and Background, Prev: Initializing the Shell, Up: Implementing a Shell
  2575. 28.5.3 Launching Jobs
  2576. ---------------------
  2577. Once the shell has taken responsibility for performing job control on
  2578. its controlling terminal, it can launch jobs in response to commands
  2579. typed by the user.
  2580. To create the processes in a process group, you use the same ‘fork’
  2581. and ‘exec’ functions described in *note Process Creation Concepts::.
  2582. Since there are multiple child processes involved, though, things are a
  2583. little more complicated and you must be careful to do things in the
  2584. right order. Otherwise, nasty race conditions can result.
  2585. You have two choices for how to structure the tree of parent-child
  2586. relationships among the processes. You can either make all the
  2587. processes in the process group be children of the shell process, or you
  2588. can make one process in group be the ancestor of all the other processes
  2589. in that group. The sample shell program presented in this chapter uses
  2590. the first approach because it makes bookkeeping somewhat simpler.
  2591. As each process is forked, it should put itself in the new process
  2592. group by calling ‘setpgid’; see *note Process Group Functions::. The
  2593. first process in the new group becomes its “process group leader”, and
  2594. its process ID becomes the “process group ID” for the group.
  2595. The shell should also call ‘setpgid’ to put each of its child
  2596. processes into the new process group. This is because there is a
  2597. potential timing problem: each child process must be put in the process
  2598. group before it begins executing a new program, and the shell depends on
  2599. having all the child processes in the group before it continues
  2600. executing. If both the child processes and the shell call ‘setpgid’,
  2601. this ensures that the right things happen no matter which process gets
  2602. to it first.
  2603. If the job is being launched as a foreground job, the new process
  2604. group also needs to be put into the foreground on the controlling
  2605. terminal using ‘tcsetpgrp’. Again, this should be done by the shell as
  2606. well as by each of its child processes, to avoid race conditions.
  2607. The next thing each child process should do is to reset its signal
  2608. actions.
  2609. During initialization, the shell process set itself to ignore job
  2610. control signals; see *note Initializing the Shell::. As a result, any
  2611. child processes it creates also ignore these signals by inheritance.
  2612. This is definitely undesirable, so each child process should explicitly
  2613. set the actions for these signals back to ‘SIG_DFL’ just after it is
  2614. forked.
  2615. Since shells follow this convention, applications can assume that
  2616. they inherit the correct handling of these signals from the parent
  2617. process. But every application has a responsibility not to mess up the
  2618. handling of stop signals. Applications that disable the normal
  2619. interpretation of the SUSP character should provide some other mechanism
  2620. for the user to stop the job. When the user invokes this mechanism, the
  2621. program should send a ‘SIGTSTP’ signal to the process group of the
  2622. process, not just to the process itself. *Note Signaling Another
  2623. Process::.
  2624. Finally, each child process should call ‘exec’ in the normal way.
  2625. This is also the point at which redirection of the standard input and
  2626. output channels should be handled. *Note Duplicating Descriptors::, for
  2627. an explanation of how to do this.
  2628. Here is the function from the sample shell program that is
  2629. responsible for launching a program. The function is executed by each
  2630. child process immediately after it has been forked by the shell, and
  2631. never returns.
  2632. void
  2633. launch_process (process *p, pid_t pgid,
  2634. int infile, int outfile, int errfile,
  2635. int foreground)
  2636. {
  2637. pid_t pid;
  2638. if (shell_is_interactive)
  2639. {
  2640. /* Put the process into the process group and give the process group
  2641. the terminal, if appropriate.
  2642. This has to be done both by the shell and in the individual
  2643. child processes because of potential race conditions. */
  2644. pid = getpid ();
  2645. if (pgid == 0) pgid = pid;
  2646. setpgid (pid, pgid);
  2647. if (foreground)
  2648. tcsetpgrp (shell_terminal, pgid);
  2649. /* Set the handling for job control signals back to the default. */
  2650. signal (SIGINT, SIG_DFL);
  2651. signal (SIGQUIT, SIG_DFL);
  2652. signal (SIGTSTP, SIG_DFL);
  2653. signal (SIGTTIN, SIG_DFL);
  2654. signal (SIGTTOU, SIG_DFL);
  2655. signal (SIGCHLD, SIG_DFL);
  2656. }
  2657. /* Set the standard input/output channels of the new process. */
  2658. if (infile != STDIN_FILENO)
  2659. {
  2660. dup2 (infile, STDIN_FILENO);
  2661. close (infile);
  2662. }
  2663. if (outfile != STDOUT_FILENO)
  2664. {
  2665. dup2 (outfile, STDOUT_FILENO);
  2666. close (outfile);
  2667. }
  2668. if (errfile != STDERR_FILENO)
  2669. {
  2670. dup2 (errfile, STDERR_FILENO);
  2671. close (errfile);
  2672. }
  2673. /* Exec the new process. Make sure we exit. */
  2674. execvp (p->argv[0], p->argv);
  2675. perror ("execvp");
  2676. exit (1);
  2677. }
  2678. If the shell is not running interactively, this function does not do
  2679. anything with process groups or signals. Remember that a shell not
  2680. performing job control must keep all of its subprocesses in the same
  2681. process group as the shell itself.
  2682. Next, here is the function that actually launches a complete job.
  2683. After creating the child processes, this function calls some other
  2684. functions to put the newly created job into the foreground or
  2685. background; these are discussed in *note Foreground and Background::.
  2686. void
  2687. launch_job (job *j, int foreground)
  2688. {
  2689. process *p;
  2690. pid_t pid;
  2691. int mypipe[2], infile, outfile;
  2692. infile = j->stdin;
  2693. for (p = j->first_process; p; p = p->next)
  2694. {
  2695. /* Set up pipes, if necessary. */
  2696. if (p->next)
  2697. {
  2698. if (pipe (mypipe) < 0)
  2699. {
  2700. perror ("pipe");
  2701. exit (1);
  2702. }
  2703. outfile = mypipe[1];
  2704. }
  2705. else
  2706. outfile = j->stdout;
  2707. /* Fork the child processes. */
  2708. pid = fork ();
  2709. if (pid == 0)
  2710. /* This is the child process. */
  2711. launch_process (p, j->pgid, infile,
  2712. outfile, j->stderr, foreground);
  2713. else if (pid < 0)
  2714. {
  2715. /* The fork failed. */
  2716. perror ("fork");
  2717. exit (1);
  2718. }
  2719. else
  2720. {
  2721. /* This is the parent process. */
  2722. p->pid = pid;
  2723. if (shell_is_interactive)
  2724. {
  2725. if (!j->pgid)
  2726. j->pgid = pid;
  2727. setpgid (pid, j->pgid);
  2728. }
  2729. }
  2730. /* Clean up after pipes. */
  2731. if (infile != j->stdin)
  2732. close (infile);
  2733. if (outfile != j->stdout)
  2734. close (outfile);
  2735. infile = mypipe[0];
  2736. }
  2737. format_job_info (j, "launched");
  2738. if (!shell_is_interactive)
  2739. wait_for_job (j);
  2740. else if (foreground)
  2741. put_job_in_foreground (j, 0);
  2742. else
  2743. put_job_in_background (j, 0);
  2744. }
  2745. 
  2746. File: libc.info, Node: Foreground and Background, Next: Stopped and Terminated Jobs, Prev: Launching Jobs, Up: Implementing a Shell
  2747. 28.5.4 Foreground and Background
  2748. --------------------------------
  2749. Now let’s consider what actions must be taken by the shell when it
  2750. launches a job into the foreground, and how this differs from what must
  2751. be done when a background job is launched.
  2752. When a foreground job is launched, the shell must first give it
  2753. access to the controlling terminal by calling ‘tcsetpgrp’. Then, the
  2754. shell should wait for processes in that process group to terminate or
  2755. stop. This is discussed in more detail in *note Stopped and Terminated
  2756. Jobs::.
  2757. When all of the processes in the group have either completed or
  2758. stopped, the shell should regain control of the terminal for its own
  2759. process group by calling ‘tcsetpgrp’ again. Since stop signals caused
  2760. by I/O from a background process or a SUSP character typed by the user
  2761. are sent to the process group, normally all the processes in the job
  2762. stop together.
  2763. The foreground job may have left the terminal in a strange state, so
  2764. the shell should restore its own saved terminal modes before continuing.
  2765. In case the job is merely stopped, the shell should first save the
  2766. current terminal modes so that it can restore them later if the job is
  2767. continued. The functions for dealing with terminal modes are
  2768. ‘tcgetattr’ and ‘tcsetattr’; these are described in *note Terminal
  2769. Modes::.
  2770. Here is the sample shell’s function for doing all of this.
  2771. /* Put job J in the foreground. If CONT is nonzero,
  2772. restore the saved terminal modes and send the process group a
  2773. ‘SIGCONT’ signal to wake it up before we block. */
  2774. void
  2775. put_job_in_foreground (job *j, int cont)
  2776. {
  2777. /* Put the job into the foreground. */
  2778. tcsetpgrp (shell_terminal, j->pgid);
  2779. /* Send the job a continue signal, if necessary. */
  2780. if (cont)
  2781. {
  2782. tcsetattr (shell_terminal, TCSADRAIN, &j->tmodes);
  2783. if (kill (- j->pgid, SIGCONT) < 0)
  2784. perror ("kill (SIGCONT)");
  2785. }
  2786. /* Wait for it to report. */
  2787. wait_for_job (j);
  2788. /* Put the shell back in the foreground. */
  2789. tcsetpgrp (shell_terminal, shell_pgid);
  2790. /* Restore the shell’s terminal modes. */
  2791. tcgetattr (shell_terminal, &j->tmodes);
  2792. tcsetattr (shell_terminal, TCSADRAIN, &shell_tmodes);
  2793. }
  2794. If the process group is launched as a background job, the shell
  2795. should remain in the foreground itself and continue to read commands
  2796. from the terminal.
  2797. In the sample shell, there is not much that needs to be done to put a
  2798. job into the background. Here is the function it uses:
  2799. /* Put a job in the background. If the cont argument is true, send
  2800. the process group a ‘SIGCONT’ signal to wake it up. */
  2801. void
  2802. put_job_in_background (job *j, int cont)
  2803. {
  2804. /* Send the job a continue signal, if necessary. */
  2805. if (cont)
  2806. if (kill (-j->pgid, SIGCONT) < 0)
  2807. perror ("kill (SIGCONT)");
  2808. }
  2809. 
  2810. File: libc.info, Node: Stopped and Terminated Jobs, Next: Continuing Stopped Jobs, Prev: Foreground and Background, Up: Implementing a Shell
  2811. 28.5.5 Stopped and Terminated Jobs
  2812. ----------------------------------
  2813. When a foreground process is launched, the shell must block until all of
  2814. the processes in that job have either terminated or stopped. It can do
  2815. this by calling the ‘waitpid’ function; see *note Process Completion::.
  2816. Use the ‘WUNTRACED’ option so that status is reported for processes that
  2817. stop as well as processes that terminate.
  2818. The shell must also check on the status of background jobs so that it
  2819. can report terminated and stopped jobs to the user; this can be done by
  2820. calling ‘waitpid’ with the ‘WNOHANG’ option. A good place to put a such
  2821. a check for terminated and stopped jobs is just before prompting for a
  2822. new command.
  2823. The shell can also receive asynchronous notification that there is
  2824. status information available for a child process by establishing a
  2825. handler for ‘SIGCHLD’ signals. *Note Signal Handling::.
  2826. In the sample shell program, the ‘SIGCHLD’ signal is normally
  2827. ignored. This is to avoid reentrancy problems involving the global data
  2828. structures the shell manipulates. But at specific times when the shell
  2829. is not using these data structures—such as when it is waiting for input
  2830. on the terminal—it makes sense to enable a handler for ‘SIGCHLD’. The
  2831. same function that is used to do the synchronous status checks
  2832. (‘do_job_notification’, in this case) can also be called from within
  2833. this handler.
  2834. Here are the parts of the sample shell program that deal with
  2835. checking the status of jobs and reporting the information to the user.
  2836. /* Store the status of the process PID that was returned by waitpid.
  2837. Return 0 if all went well, nonzero otherwise. */
  2838. int
  2839. mark_process_status (pid_t pid, int status)
  2840. {
  2841. job *j;
  2842. process *p;
  2843. if (pid > 0)
  2844. {
  2845. /* Update the record for the process. */
  2846. for (j = first_job; j; j = j->next)
  2847. for (p = j->first_process; p; p = p->next)
  2848. if (p->pid == pid)
  2849. {
  2850. p->status = status;
  2851. if (WIFSTOPPED (status))
  2852. p->stopped = 1;
  2853. else
  2854. {
  2855. p->completed = 1;
  2856. if (WIFSIGNALED (status))
  2857. fprintf (stderr, "%d: Terminated by signal %d.\n",
  2858. (int) pid, WTERMSIG (p->status));
  2859. }
  2860. return 0;
  2861. }
  2862. fprintf (stderr, "No child process %d.\n", pid);
  2863. return -1;
  2864. }
  2865. else if (pid == 0 || errno == ECHILD)
  2866. /* No processes ready to report. */
  2867. return -1;
  2868. else {
  2869. /* Other weird errors. */
  2870. perror ("waitpid");
  2871. return -1;
  2872. }
  2873. }
  2874. /* Check for processes that have status information available,
  2875. without blocking. */
  2876. void
  2877. update_status (void)
  2878. {
  2879. int status;
  2880. pid_t pid;
  2881. do
  2882. pid = waitpid (WAIT_ANY, &status, WUNTRACED|WNOHANG);
  2883. while (!mark_process_status (pid, status));
  2884. }
  2885. /* Check for processes that have status information available,
  2886. blocking until all processes in the given job have reported. */
  2887. void
  2888. wait_for_job (job *j)
  2889. {
  2890. int status;
  2891. pid_t pid;
  2892. do
  2893. pid = waitpid (WAIT_ANY, &status, WUNTRACED);
  2894. while (!mark_process_status (pid, status)
  2895. && !job_is_stopped (j)
  2896. && !job_is_completed (j));
  2897. }
  2898. /* Format information about job status for the user to look at. */
  2899. void
  2900. format_job_info (job *j, const char *status)
  2901. {
  2902. fprintf (stderr, "%ld (%s): %s\n", (long)j->pgid, status, j->command);
  2903. }
  2904. /* Notify the user about stopped or terminated jobs.
  2905. Delete terminated jobs from the active job list. */
  2906. void
  2907. do_job_notification (void)
  2908. {
  2909. job *j, *jlast, *jnext;
  2910. /* Update status information for child processes. */
  2911. update_status ();
  2912. jlast = NULL;
  2913. for (j = first_job; j; j = jnext)
  2914. {
  2915. jnext = j->next;
  2916. /* If all processes have completed, tell the user the job has
  2917. completed and delete it from the list of active jobs. */
  2918. if (job_is_completed (j)) {
  2919. format_job_info (j, "completed");
  2920. if (jlast)
  2921. jlast->next = jnext;
  2922. else
  2923. first_job = jnext;
  2924. free_job (j);
  2925. }
  2926. /* Notify the user about stopped jobs,
  2927. marking them so that we won’t do this more than once. */
  2928. else if (job_is_stopped (j) && !j->notified) {
  2929. format_job_info (j, "stopped");
  2930. j->notified = 1;
  2931. jlast = j;
  2932. }
  2933. /* Don’t say anything about jobs that are still running. */
  2934. else
  2935. jlast = j;
  2936. }
  2937. }
  2938. 
  2939. File: libc.info, Node: Continuing Stopped Jobs, Next: Missing Pieces, Prev: Stopped and Terminated Jobs, Up: Implementing a Shell
  2940. 28.5.6 Continuing Stopped Jobs
  2941. ------------------------------
  2942. The shell can continue a stopped job by sending a ‘SIGCONT’ signal to
  2943. its process group. If the job is being continued in the foreground, the
  2944. shell should first invoke ‘tcsetpgrp’ to give the job access to the
  2945. terminal, and restore the saved terminal settings. After continuing a
  2946. job in the foreground, the shell should wait for the job to stop or
  2947. complete, as if the job had just been launched in the foreground.
  2948. The sample shell program handles both newly created and continued
  2949. jobs with the same pair of functions, ‘put_job_in_foreground’ and
  2950. ‘put_job_in_background’. The definitions of these functions were given
  2951. in *note Foreground and Background::. When continuing a stopped job, a
  2952. nonzero value is passed as the CONT argument to ensure that the
  2953. ‘SIGCONT’ signal is sent and the terminal modes reset, as appropriate.
  2954. This leaves only a function for updating the shell’s internal
  2955. bookkeeping about the job being continued:
  2956. /* Mark a stopped job J as being running again. */
  2957. void
  2958. mark_job_as_running (job *j)
  2959. {
  2960. Process *p;
  2961. for (p = j->first_process; p; p = p->next)
  2962. p->stopped = 0;
  2963. j->notified = 0;
  2964. }
  2965. /* Continue the job J. */
  2966. void
  2967. continue_job (job *j, int foreground)
  2968. {
  2969. mark_job_as_running (j);
  2970. if (foreground)
  2971. put_job_in_foreground (j, 1);
  2972. else
  2973. put_job_in_background (j, 1);
  2974. }
  2975. 
  2976. File: libc.info, Node: Missing Pieces, Prev: Continuing Stopped Jobs, Up: Implementing a Shell
  2977. 28.5.7 The Missing Pieces
  2978. -------------------------
  2979. The code extracts for the sample shell included in this chapter are only
  2980. a part of the entire shell program. In particular, nothing at all has
  2981. been said about how ‘job’ and ‘program’ data structures are allocated
  2982. and initialized.
  2983. Most real shells provide a complex user interface that has support
  2984. for a command language; variables; abbreviations, substitutions, and
  2985. pattern matching on file names; and the like. All of this is far too
  2986. complicated to explain here! Instead, we have concentrated on showing
  2987. how to implement the core process creation and job control functions
  2988. that can be called from such a shell.
  2989. Here is a table summarizing the major entry points we have presented:
  2990. ‘void init_shell (void)’
  2991. Initialize the shell’s internal state. *Note Initializing the
  2992. Shell::.
  2993. ‘void launch_job (job *J, int FOREGROUND)’
  2994. Launch the job J as either a foreground or background job. *Note
  2995. Launching Jobs::.
  2996. ‘void do_job_notification (void)’
  2997. Check for and report any jobs that have terminated or stopped. Can
  2998. be called synchronously or within a handler for ‘SIGCHLD’ signals.
  2999. *Note Stopped and Terminated Jobs::.
  3000. ‘void continue_job (job *J, int FOREGROUND)’
  3001. Continue the job J. *Note Continuing Stopped Jobs::.
  3002. Of course, a real shell would also want to provide other functions
  3003. for managing jobs. For example, it would be useful to have commands to
  3004. list all active jobs or to send a signal (such as ‘SIGKILL’) to a job.
  3005. 
  3006. File: libc.info, Node: Functions for Job Control, Prev: Implementing a Shell, Up: Job Control
  3007. 28.6 Functions for Job Control
  3008. ==============================
  3009. This section contains detailed descriptions of the functions relating to
  3010. job control.
  3011. * Menu:
  3012. * Identifying the Terminal:: Determining the controlling terminal’s name.
  3013. * Process Group Functions:: Functions for manipulating process groups.
  3014. * Terminal Access Functions:: Functions for controlling terminal access.
  3015. 
  3016. File: libc.info, Node: Identifying the Terminal, Next: Process Group Functions, Up: Functions for Job Control
  3017. 28.6.1 Identifying the Controlling Terminal
  3018. -------------------------------------------
  3019. You can use the ‘ctermid’ function to get a file name that you can use
  3020. to open the controlling terminal. In the GNU C Library, it returns the
  3021. same string all the time: ‘"/dev/tty"’. That is a special “magic” file
  3022. name that refers to the controlling terminal of the current process (if
  3023. it has one). To find the name of the specific terminal device, use
  3024. ‘ttyname’; *note Is It a Terminal::.
  3025. The function ‘ctermid’ is declared in the header file ‘stdio.h’.
  3026. -- Function: char * ctermid (char *STRING)
  3027. Preliminary: | MT-Safe !posix/!string | AS-Safe | AC-Safe | *Note
  3028. POSIX Safety Concepts::.
  3029. The ‘ctermid’ function returns a string containing the file name of
  3030. the controlling terminal for the current process. If STRING is not
  3031. a null pointer, it should be an array that can hold at least
  3032. ‘L_ctermid’ characters; the string is returned in this array.
  3033. Otherwise, a pointer to a string in a static area is returned,
  3034. which might get overwritten on subsequent calls to this function.
  3035. An empty string is returned if the file name cannot be determined
  3036. for any reason. Even if a file name is returned, access to the
  3037. file it represents is not guaranteed.
  3038. -- Macro: int L_ctermid
  3039. The value of this macro is an integer constant expression that
  3040. represents the size of a string large enough to hold the file name
  3041. returned by ‘ctermid’.
  3042. See also the ‘isatty’ and ‘ttyname’ functions, in *note Is It a
  3043. Terminal::.
  3044. 
  3045. File: libc.info, Node: Process Group Functions, Next: Terminal Access Functions, Prev: Identifying the Terminal, Up: Functions for Job Control
  3046. 28.6.2 Process Group Functions
  3047. ------------------------------
  3048. Here are descriptions of the functions for manipulating process groups.
  3049. Your program should include the header files ‘sys/types.h’ and
  3050. ‘unistd.h’ to use these functions.
  3051. -- Function: pid_t setsid (void)
  3052. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3053. Concepts::.
  3054. The ‘setsid’ function creates a new session. The calling process
  3055. becomes the session leader, and is put in a new process group whose
  3056. process group ID is the same as the process ID of that process.
  3057. There are initially no other processes in the new process group,
  3058. and no other process groups in the new session.
  3059. This function also makes the calling process have no controlling
  3060. terminal.
  3061. The ‘setsid’ function returns the new process group ID of the
  3062. calling process if successful. A return value of ‘-1’ indicates an
  3063. error. The following ‘errno’ error conditions are defined for this
  3064. function:
  3065. ‘EPERM’
  3066. The calling process is already a process group leader, or
  3067. there is already another process group around that has the
  3068. same process group ID.
  3069. -- Function: pid_t getsid (pid_t PID)
  3070. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3071. Concepts::.
  3072. The ‘getsid’ function returns the process group ID of the session
  3073. leader of the specified process. If a PID is ‘0’, the process
  3074. group ID of the session leader of the current process is returned.
  3075. In case of error ‘-1’ is returned and ‘errno’ is set. The
  3076. following ‘errno’ error conditions are defined for this function:
  3077. ‘ESRCH’
  3078. There is no process with the given process ID PID.
  3079. ‘EPERM’
  3080. The calling process and the process specified by PID are in
  3081. different sessions, and the implementation doesn’t allow to
  3082. access the process group ID of the session leader of the
  3083. process with ID PID from the calling process.
  3084. -- Function: pid_t getpgrp (void)
  3085. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3086. Concepts::.
  3087. The ‘getpgrp’ function returns the process group ID of the calling
  3088. process.
  3089. -- Function: int getpgid (pid_t PID)
  3090. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3091. Concepts::.
  3092. The ‘getpgid’ function returns the process group ID of the process
  3093. PID. You can supply a value of ‘0’ for the PID argument to get
  3094. information about the calling process.
  3095. In case of error ‘-1’ is returned and ‘errno’ is set. The
  3096. following ‘errno’ error conditions are defined for this function:
  3097. ‘ESRCH’
  3098. There is no process with the given process ID PID. The
  3099. calling process and the process specified by PID are in
  3100. different sessions, and the implementation doesn’t allow to
  3101. access the process group ID of the process with ID PID from
  3102. the calling process.
  3103. -- Function: int setpgid (pid_t PID, pid_t PGID)
  3104. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3105. Concepts::.
  3106. The ‘setpgid’ function puts the process PID into the process group
  3107. PGID. As a special case, either PID or PGID can be zero to
  3108. indicate the process ID of the calling process.
  3109. If the operation is successful, ‘setpgid’ returns zero. Otherwise
  3110. it returns ‘-1’. The following ‘errno’ error conditions are
  3111. defined for this function:
  3112. ‘EACCES’
  3113. The child process named by PID has executed an ‘exec’ function
  3114. since it was forked.
  3115. ‘EINVAL’
  3116. The value of the PGID is not valid.
  3117. ‘ENOSYS’
  3118. The system doesn’t support job control.
  3119. ‘EPERM’
  3120. The process indicated by the PID argument is a session leader,
  3121. or is not in the same session as the calling process, or the
  3122. value of the PGID argument doesn’t match a process group ID in
  3123. the same session as the calling process.
  3124. ‘ESRCH’
  3125. The process indicated by the PID argument is not the calling
  3126. process or a child of the calling process.
  3127. -- Function: int setpgrp (pid_t PID, pid_t PGID)
  3128. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3129. Concepts::.
  3130. This is the BSD Unix name for ‘setpgid’. Both functions do exactly
  3131. the same thing.
  3132. 
  3133. File: libc.info, Node: Terminal Access Functions, Prev: Process Group Functions, Up: Functions for Job Control
  3134. 28.6.3 Functions for Controlling Terminal Access
  3135. ------------------------------------------------
  3136. These are the functions for reading or setting the foreground process
  3137. group of a terminal. You should include the header files ‘sys/types.h’
  3138. and ‘unistd.h’ in your application to use these functions.
  3139. Although these functions take a file descriptor argument to specify
  3140. the terminal device, the foreground job is associated with the terminal
  3141. file itself and not a particular open file descriptor.
  3142. -- Function: pid_t tcgetpgrp (int FILEDES)
  3143. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3144. Concepts::.
  3145. This function returns the process group ID of the foreground
  3146. process group associated with the terminal open on descriptor
  3147. FILEDES.
  3148. If there is no foreground process group, the return value is a
  3149. number greater than ‘1’ that does not match the process group ID of
  3150. any existing process group. This can happen if all of the
  3151. processes in the job that was formerly the foreground job have
  3152. terminated, and no other job has yet been moved into the
  3153. foreground.
  3154. In case of an error, a value of ‘-1’ is returned. The following
  3155. ‘errno’ error conditions are defined for this function:
  3156. ‘EBADF’
  3157. The FILEDES argument is not a valid file descriptor.
  3158. ‘ENOSYS’
  3159. The system doesn’t support job control.
  3160. ‘ENOTTY’
  3161. The terminal file associated with the FILEDES argument isn’t
  3162. the controlling terminal of the calling process.
  3163. -- Function: int tcsetpgrp (int FILEDES, pid_t PGID)
  3164. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3165. Concepts::.
  3166. This function is used to set a terminal’s foreground process group
  3167. ID. The argument FILEDES is a descriptor which specifies the
  3168. terminal; PGID specifies the process group. The calling process
  3169. must be a member of the same session as PGID and must have the same
  3170. controlling terminal.
  3171. For terminal access purposes, this function is treated as output.
  3172. If it is called from a background process on its controlling
  3173. terminal, normally all processes in the process group are sent a
  3174. ‘SIGTTOU’ signal. The exception is if the calling process itself
  3175. is ignoring or blocking ‘SIGTTOU’ signals, in which case the
  3176. operation is performed and no signal is sent.
  3177. If successful, ‘tcsetpgrp’ returns ‘0’. A return value of ‘-1’
  3178. indicates an error. The following ‘errno’ error conditions are
  3179. defined for this function:
  3180. ‘EBADF’
  3181. The FILEDES argument is not a valid file descriptor.
  3182. ‘EINVAL’
  3183. The PGID argument is not valid.
  3184. ‘ENOSYS’
  3185. The system doesn’t support job control.
  3186. ‘ENOTTY’
  3187. The FILEDES isn’t the controlling terminal of the calling
  3188. process.
  3189. ‘EPERM’
  3190. The PGID isn’t a process group in the same session as the
  3191. calling process.
  3192. -- Function: pid_t tcgetsid (int FILDES)
  3193. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3194. Concepts::.
  3195. This function is used to obtain the process group ID of the session
  3196. for which the terminal specified by FILDES is the controlling
  3197. terminal. If the call is successful the group ID is returned.
  3198. Otherwise the return value is ‘(pid_t) -1’ and the global variable
  3199. ‘errno’ is set to the following value:
  3200. ‘EBADF’
  3201. The FILEDES argument is not a valid file descriptor.
  3202. ‘ENOTTY’
  3203. The calling process does not have a controlling terminal, or
  3204. the file is not the controlling terminal.
  3205. 
  3206. File: libc.info, Node: Name Service Switch, Next: Users and Groups, Prev: Job Control, Up: Top
  3207. 29 System Databases and Name Service Switch
  3208. *******************************************
  3209. Various functions in the C Library need to be configured to work
  3210. correctly in the local environment. Traditionally, this was done by
  3211. using files (e.g., ‘/etc/passwd’), but other nameservices (like the
  3212. Network Information Service (NIS) and the Domain Name Service (DNS))
  3213. became popular, and were hacked into the C library, usually with a fixed
  3214. search order.
  3215. The GNU C Library contains a cleaner solution to this problem. It is
  3216. designed after a method used by Sun Microsystems in the C library of
  3217. Solaris 2. The GNU C Library follows their name and calls this scheme
  3218. “Name Service Switch” (NSS).
  3219. Though the interface might be similar to Sun’s version there is no
  3220. common code. We never saw any source code of Sun’s implementation and
  3221. so the internal interface is incompatible. This also manifests in the
  3222. file names we use as we will see later.
  3223. * Menu:
  3224. * NSS Basics:: What is this NSS good for.
  3225. * NSS Configuration File:: Configuring NSS.
  3226. * NSS Module Internals:: How does it work internally.
  3227. * Extending NSS:: What to do to add services or databases.
  3228. 
  3229. File: libc.info, Node: NSS Basics, Next: NSS Configuration File, Prev: Name Service Switch, Up: Name Service Switch
  3230. 29.1 NSS Basics
  3231. ===============
  3232. The basic idea is to put the implementation of the different services
  3233. offered to access the databases in separate modules. This has some
  3234. advantages:
  3235. 1. Contributors can add new services without adding them to the GNU C
  3236. Library.
  3237. 2. The modules can be updated separately.
  3238. 3. The C library image is smaller.
  3239. To fulfill the first goal above, the ABI of the modules will be
  3240. described below. For getting the implementation of a new service right
  3241. it is important to understand how the functions in the modules get
  3242. called. They are in no way designed to be used by the programmer
  3243. directly. Instead the programmer should only use the documented and
  3244. standardized functions to access the databases.
  3245. The databases available in the NSS are
  3246. ‘aliases’
  3247. Mail aliases
  3248. ‘ethers’
  3249. Ethernet numbers,
  3250. ‘group’
  3251. Groups of users, *note Group Database::.
  3252. ‘gshadow’
  3253. Group passphrase hashes and related information.
  3254. ‘hosts’
  3255. Host names and numbers, *note Host Names::.
  3256. ‘initgroups’
  3257. Supplementary group access list.
  3258. ‘netgroup’
  3259. Network wide list of host and users, *note Netgroup Database::.
  3260. ‘networks’
  3261. Network names and numbers, *note Networks Database::.
  3262. ‘passwd’
  3263. User identities, *note User Database::.
  3264. ‘protocols’
  3265. Network protocols, *note Protocols Database::.
  3266. ‘publickey’
  3267. Public keys for Secure RPC.
  3268. ‘rpc’
  3269. Remote procedure call names and numbers.
  3270. ‘services’
  3271. Network services, *note Services Database::.
  3272. ‘shadow’
  3273. User passphrase hashes and related information.
  3274. More databases may be added later.
  3275. 
  3276. File: libc.info, Node: NSS Configuration File, Next: NSS Module Internals, Prev: NSS Basics, Up: Name Service Switch
  3277. 29.2 The NSS Configuration File
  3278. ===============================
  3279. Somehow the NSS code must be told about the wishes of the user. For
  3280. this reason there is the file ‘/etc/nsswitch.conf’. For each database,
  3281. this file contains a specification of how the lookup process should
  3282. work. The file could look like this:
  3283. # /etc/nsswitch.conf
  3284. #
  3285. # Name Service Switch configuration file.
  3286. #
  3287. passwd: db files
  3288. shadow: files
  3289. group: db files
  3290. hosts: files dns
  3291. networks: files
  3292. ethers: db files
  3293. protocols: db files
  3294. rpc: db files
  3295. services: db files
  3296. The first column is the database as you can guess from the table
  3297. above. The rest of the line specifies how the lookup process works.
  3298. Please note that you specify the way it works for each database
  3299. individually. This cannot be done with the old way of a monolithic
  3300. implementation.
  3301. The configuration specification for each database can contain two
  3302. different items:
  3303. • the service specification like ‘files’, ‘db’, or ‘nis’.
  3304. • the reaction on lookup result like ‘[NOTFOUND=return]’.
  3305. * Menu:
  3306. * Services in the NSS configuration:: Service names in the NSS configuration.
  3307. * Actions in the NSS configuration:: React appropriately to the lookup result.
  3308. * Notes on NSS Configuration File:: Things to take care about while
  3309. configuring NSS.
  3310. 
  3311. File: libc.info, Node: Services in the NSS configuration, Next: Actions in the NSS configuration, Prev: NSS Configuration File, Up: NSS Configuration File
  3312. 29.2.1 Services in the NSS configuration File
  3313. ---------------------------------------------
  3314. The above example file mentions five different services: ‘files’, ‘db’,
  3315. ‘dns’, ‘nis’, and ‘nisplus’. This does not mean these services are
  3316. available on all sites and neither does it mean these are all the
  3317. services which will ever be available.
  3318. In fact, these names are simply strings which the NSS code uses to
  3319. find the implicitly addressed functions. The internal interface will be
  3320. described later. Visible to the user are the modules which implement an
  3321. individual service.
  3322. Assume the service NAME shall be used for a lookup. The code for
  3323. this service is implemented in a module called ‘libnss_NAME’. On a
  3324. system supporting shared libraries this is in fact a shared library with
  3325. the name (for example) ‘libnss_NAME.so.2’. The number at the end is the
  3326. currently used version of the interface which will not change
  3327. frequently. Normally the user should not have to be cognizant of these
  3328. files since they should be placed in a directory where they are found
  3329. automatically. Only the names of all available services are important.
  3330. Lastly, some system software may make use of the NSS configuration
  3331. file to store their own configuration for similar purposes. Examples of
  3332. this include the ‘automount’ service which is used by ‘autofs’.
  3333. 
  3334. File: libc.info, Node: Actions in the NSS configuration, Next: Notes on NSS Configuration File, Prev: Services in the NSS configuration, Up: NSS Configuration File
  3335. 29.2.2 Actions in the NSS configuration
  3336. ---------------------------------------
  3337. The second item in the specification gives the user much finer control
  3338. on the lookup process. Action items are placed between two service
  3339. names and are written within brackets. The general form is
  3340. ‘[’ ( ‘!’? STATUS ‘=’ ACTION )+ ‘]’
  3341. where
  3342. STATUS ⇒ success | notfound | unavail | tryagain
  3343. ACTION ⇒ return | continue
  3344. The case of the keywords is insignificant. The STATUS values are the
  3345. results of a call to a lookup function of a specific service. They
  3346. mean:
  3347. ‘success’
  3348. No error occurred and the wanted entry is returned. The default
  3349. action for this is ‘return’.
  3350. ‘notfound’
  3351. The lookup process works ok but the needed value was not found.
  3352. The default action is ‘continue’.
  3353. ‘unavail’
  3354. The service is permanently unavailable. This can either mean the
  3355. needed file is not available, or, for DNS, the server is not
  3356. available or does not allow queries. The default action is
  3357. ‘continue’.
  3358. ‘tryagain’
  3359. The service is temporarily unavailable. This could mean a file is
  3360. locked or a server currently cannot accept more connections. The
  3361. default action is ‘continue’.
  3362. The ACTION values mean:
  3363. ‘return’
  3364. If the status matches, stop the lookup process at this service
  3365. specification. If an entry is available, provide it to the
  3366. application. If an error occurred, report it to the application.
  3367. In case of a prior ‘merge’ action, the data is combined with
  3368. previous lookup results, as explained below.
  3369. ‘continue’
  3370. If the status matches, proceed with the lookup process at the next
  3371. entry, discarding the result of the current lookup (and any merged
  3372. data). An exception is the ‘initgroups’ database and the ‘success’
  3373. status, where ‘continue’ acts like ‘merge’ below.
  3374. ‘merge’
  3375. Proceed with the lookup process, retaining the current lookup
  3376. result. This action is useful only with the ‘success’ status. If
  3377. a subsequent service lookup succeeds and has a matching ‘return’
  3378. specification, the results are merged, the lookup process ends, and
  3379. the merged results are returned to the application. If the
  3380. following service has a matching ‘merge’ action, the lookup process
  3381. continues, retaining the combined data from this and any previous
  3382. lookups.
  3383. After a ‘merge’ action, errors from subsequent lookups are ignored,
  3384. and the data gathered so far will be returned.
  3385. The ‘merge’ only applies to the ‘success’ status. It is currently
  3386. implemented for the ‘group’ database and its group members field,
  3387. ‘gr_mem’. If specified for other databases, it causes the lookup
  3388. to fail (if the STATUS matches).
  3389. When processing ‘merge’ for ‘group’ membership, the group GID and
  3390. name must be identical for both entries. If only one or the other
  3391. is a match, the behavior is undefined.
  3392. If we have a line like
  3393. ethers: nisplus [NOTFOUND=return] db files
  3394. this is equivalent to
  3395. ethers: nisplus [SUCCESS=return NOTFOUND=return UNAVAIL=continue
  3396. TRYAGAIN=continue]
  3397. db [SUCCESS=return NOTFOUND=continue UNAVAIL=continue
  3398. TRYAGAIN=continue]
  3399. files
  3400. (except that it would have to be written on one line). The default
  3401. value for the actions are normally what you want, and only need to be
  3402. changed in exceptional cases.
  3403. If the optional ‘!’ is placed before the STATUS this means the
  3404. following action is used for all statuses but STATUS itself. I.e., ‘!’
  3405. is negation as in the C language (and others).
  3406. Before we explain the exception which makes this action item
  3407. necessary one more remark: obviously it makes no sense to add another
  3408. action item after the ‘files’ service. Since there is no other service
  3409. following the action _always_ is ‘return’.
  3410. Now, why is this ‘[NOTFOUND=return]’ action useful? To understand
  3411. this we should know that the ‘nisplus’ service is often complete; i.e.,
  3412. if an entry is not available in the NIS+ tables it is not available
  3413. anywhere else. This is what is expressed by this action item: it is
  3414. useless to examine further services since they will not give us a
  3415. result.
  3416. The situation would be different if the NIS+ service is not available
  3417. because the machine is booting. In this case the return value of the
  3418. lookup function is not ‘notfound’ but instead ‘unavail’. And as you can
  3419. see in the complete form above: in this situation the ‘db’ and ‘files’
  3420. services are used. Neat, isn’t it? The system administrator need not
  3421. pay special care for the time the system is not completely ready to work
  3422. (while booting or shutdown or network problems).
  3423. 
  3424. File: libc.info, Node: Notes on NSS Configuration File, Prev: Actions in the NSS configuration, Up: NSS Configuration File
  3425. 29.2.3 Notes on the NSS Configuration File
  3426. ------------------------------------------
  3427. Finally a few more hints. The NSS implementation is not completely
  3428. helpless if ‘/etc/nsswitch.conf’ does not exist. For all supported
  3429. databases there is a default value so it should normally be possible to
  3430. get the system running even if the file is corrupted or missing.
  3431. For the ‘hosts’ and ‘networks’ databases the default value is ‘dns
  3432. [!UNAVAIL=return] files’. I.e., the system is prepared for the DNS
  3433. service not to be available but if it is available the answer it returns
  3434. is definitive.
  3435. The ‘passwd’, ‘group’, and ‘shadow’ databases was traditionally
  3436. handled in a special way. The appropriate files in the ‘/etc’ directory
  3437. were read but if an entry with a name starting with a ‘+’ character was
  3438. found NIS was used. This kind of lookup was removed and now the default
  3439. value for the services is ‘files’. libnss_compat no longer depends on
  3440. libnsl and can be used without NIS.
  3441. For all other databases the default value is ‘files’.
  3442. A second point is that the user should try to optimize the lookup
  3443. process. The different service have different response times. A simple
  3444. file look up on a local file could be fast, but if the file is long and
  3445. the needed entry is near the end of the file this may take quite some
  3446. time. In this case it might be better to use the ‘db’ service which
  3447. allows fast local access to large data sets.
  3448. Often the situation is that some global information like NIS must be
  3449. used. So it is unavoidable to use service entries like ‘nis’ etc. But
  3450. one should avoid slow services like this if possible.
  3451. 
  3452. File: libc.info, Node: NSS Module Internals, Next: Extending NSS, Prev: NSS Configuration File, Up: Name Service Switch
  3453. 29.3 NSS Module Internals
  3454. =========================
  3455. Now it is time to describe what the modules look like. The functions
  3456. contained in a module are identified by their names. I.e., there is no
  3457. jump table or the like. How this is done is of no interest here; those
  3458. interested in this topic should read about Dynamic Linking.
  3459. * Menu:
  3460. * NSS Module Names:: Construction of the interface function of
  3461. the NSS modules.
  3462. * NSS Modules Interface:: Programming interface in the NSS module
  3463. functions.
  3464. 
  3465. File: libc.info, Node: NSS Module Names, Next: NSS Modules Interface, Prev: NSS Module Internals, Up: NSS Module Internals
  3466. 29.3.1 The Naming Scheme of the NSS Modules
  3467. -------------------------------------------
  3468. The name of each function consists of various parts:
  3469. _nss_SERVICE_FUNCTION
  3470. SERVICE of course corresponds to the name of the module this function
  3471. is found in.(1) The FUNCTION part is derived from the interface
  3472. function in the C library itself. If the user calls the function
  3473. ‘gethostbyname’ and the service used is ‘files’ the function
  3474. _nss_files_gethostbyname_r
  3475. in the module
  3476. libnss_files.so.2
  3477. is used. You see, what is explained above in not the whole truth. In
  3478. fact the NSS modules only contain reentrant versions of the lookup
  3479. functions. I.e., if the user would call the ‘gethostbyname_r’ function
  3480. this also would end in the above function. For all user interface
  3481. functions the C library maps this call to a call to the reentrant
  3482. function. For reentrant functions this is trivial since the interface
  3483. is (nearly) the same. For the non-reentrant version the library keeps
  3484. internal buffers which are used to replace the user supplied buffer.
  3485. I.e., the reentrant functions _can_ have counterparts. No service
  3486. module is forced to have functions for all databases and all kinds to
  3487. access them. If a function is not available it is simply treated as if
  3488. the function would return ‘unavail’ (*note Actions in the NSS
  3489. configuration::).
  3490. The file name ‘libnss_files.so.2’ would be on a Solaris 2 system
  3491. ‘nss_files.so.2’. This is the difference mentioned above. Sun’s NSS
  3492. modules are usable as modules which get indirectly loaded only.
  3493. The NSS modules in the GNU C Library are prepared to be used as
  3494. normal libraries themselves. This is _not_ true at the moment, though.
  3495. However, the organization of the name space in the modules does not make
  3496. it impossible like it is for Solaris. Now you can see why the modules
  3497. are still libraries.(2)
  3498. ---------- Footnotes ----------
  3499. (1) Now you might ask why this information is duplicated. The answer
  3500. is that we want to make it possible to link directly with these shared
  3501. objects.
  3502. (2) There is a second explanation: we were too lazy to change the
  3503. Makefiles to allow the generation of shared objects not starting with
  3504. ‘lib’ but don’t tell this to anybody.
  3505. 
  3506. File: libc.info, Node: NSS Modules Interface, Prev: NSS Module Names, Up: NSS Module Internals
  3507. 29.3.2 The Interface of the Function in NSS Modules
  3508. ---------------------------------------------------
  3509. Now we know about the functions contained in the modules. It is now
  3510. time to describe the types. When we mentioned the reentrant versions of
  3511. the functions above, this means there are some additional arguments
  3512. (compared with the standard, non-reentrant versions). The prototypes
  3513. for the non-reentrant and reentrant versions of our function above are:
  3514. struct hostent *gethostbyname (const char *name)
  3515. int gethostbyname_r (const char *name, struct hostent *result_buf,
  3516. char *buf, size_t buflen, struct hostent **result,
  3517. int *h_errnop)
  3518. The actual prototype of the function in the NSS modules in this case is
  3519. enum nss_status _nss_files_gethostbyname_r (const char *name,
  3520. struct hostent *result_buf,
  3521. char *buf, size_t buflen,
  3522. int *errnop, int *h_errnop)
  3523. I.e., the interface function is in fact the reentrant function with
  3524. the change of the return value, the omission of the RESULT parameter,
  3525. and the addition of the ERRNOP parameter. While the user-level function
  3526. returns a pointer to the result the reentrant function return an ‘enum
  3527. nss_status’ value:
  3528. ‘NSS_STATUS_TRYAGAIN’
  3529. numeric value ‘-2’
  3530. ‘NSS_STATUS_UNAVAIL’
  3531. numeric value ‘-1’
  3532. ‘NSS_STATUS_NOTFOUND’
  3533. numeric value ‘0’
  3534. ‘NSS_STATUS_SUCCESS’
  3535. numeric value ‘1’
  3536. Now you see where the action items of the ‘/etc/nsswitch.conf’ file are
  3537. used.
  3538. If you study the source code you will find there is a fifth value:
  3539. ‘NSS_STATUS_RETURN’. This is an internal use only value, used by a few
  3540. functions in places where none of the above value can be used. If
  3541. necessary the source code should be examined to learn about the details.
  3542. In case the interface function has to return an error it is important
  3543. that the correct error code is stored in ‘*ERRNOP’. Some return status
  3544. values have only one associated error code, others have more.
  3545. ‘NSS_STATUS_TRYAGAIN’ ‘EAGAIN’ One of the functions used ran
  3546. temporarily out of resources or a
  3547. service is currently not
  3548. available.
  3549. ‘ERANGE’ The provided buffer is not large
  3550. enough. The function should be
  3551. called again with a larger buffer.
  3552. ‘NSS_STATUS_UNAVAIL’ ‘ENOENT’ A necessary input file cannot be
  3553. found.
  3554. ‘NSS_STATUS_NOTFOUND’ ‘ENOENT’ The requested entry is not
  3555. available.
  3556. ‘NSS_STATUS_NOTFOUND’ ‘SUCCESS’ There are no entries. Use this to
  3557. avoid returning errors for
  3558. inactive services which may be
  3559. enabled at a later time. This is
  3560. not the same as the service being
  3561. temporarily unavailable.
  3562. These are proposed values. There can be other error codes and the
  3563. described error codes can have different meaning. *With one exception:*
  3564. when returning ‘NSS_STATUS_TRYAGAIN’ the error code ‘ERANGE’ _must_ mean
  3565. that the user provided buffer is too small. Everything else is
  3566. non-critical.
  3567. In statically linked programs, the main application and NSS modules
  3568. do not share the same thread-local variable ‘errno’, which is the reason
  3569. why there is an explicit ERRNOP function argument.
  3570. The above function has something special which is missing for almost
  3571. all the other module functions. There is an argument H_ERRNOP. This
  3572. points to a variable which will be filled with the error code in case
  3573. the execution of the function fails for some reason. (In statically
  3574. linked programs, the thread-local variable ‘h_errno’ is not shared with
  3575. the main application.)
  3576. The ‘getXXXbyYYY’ functions are the most important functions in the
  3577. NSS modules. But there are others which implement the other ways to
  3578. access system databases (say for the user database, there are
  3579. ‘setpwent’, ‘getpwent’, and ‘endpwent’). These will be described in
  3580. more detail later. Here we give a general way to determine the
  3581. signature of the module function:
  3582. • the return value is ‘enum nss_status’;
  3583. • the name (*note NSS Module Names::);
  3584. • the first arguments are identical to the arguments of the
  3585. non-reentrant function;
  3586. • the next four arguments are:
  3587. ‘STRUCT_TYPE *result_buf’
  3588. pointer to buffer where the result is stored. ‘STRUCT_TYPE’
  3589. is normally a struct which corresponds to the database.
  3590. ‘char *buffer’
  3591. pointer to a buffer where the function can store additional
  3592. data for the result etc.
  3593. ‘size_t buflen’
  3594. length of the buffer pointed to by BUFFER.
  3595. ‘int *errnop’
  3596. the low-level error code to return to the application. If the
  3597. return value is not ‘NSS_STATUS_SUCCESS’, ‘*ERRNOP’ needs to
  3598. be set to a non-zero value. An NSS module should never set
  3599. ‘*ERRNOP’ to zero. The value ‘ERANGE’ is special, as
  3600. described above.
  3601. • possibly a last argument H_ERRNOP, for the host name and network
  3602. name lookup functions. If the return value is not
  3603. ‘NSS_STATUS_SUCCESS’, ‘*H_ERRNOP’ needs to be set to a non-zero
  3604. value. A generic error code is ‘NETDB_INTERNAL’, which instructs
  3605. the caller to examine ‘*ERRNOP’ for further details. (This
  3606. includes the ‘ERANGE’ special case.)
  3607. This table is correct for all functions but the ‘set...ent’ and
  3608. ‘end...ent’ functions.
  3609. 
  3610. File: libc.info, Node: Extending NSS, Prev: NSS Module Internals, Up: Name Service Switch
  3611. 29.4 Extending NSS
  3612. ==================
  3613. One of the advantages of NSS mentioned above is that it can be extended
  3614. quite easily. There are two ways in which the extension can happen:
  3615. adding another database or adding another service. The former is
  3616. normally done only by the C library developers. It is here only
  3617. important to remember that adding another database is independent from
  3618. adding another service because a service need not support all databases
  3619. or lookup functions.
  3620. A designer/implementer of a new service is therefore free to choose
  3621. the databases s/he is interested in and leave the rest for later (or
  3622. completely aside).
  3623. * Menu:
  3624. * Adding another Service to NSS:: What is to do to add a new service.
  3625. * NSS Module Function Internals:: Guidelines for writing new NSS
  3626. service functions.
  3627. 
  3628. File: libc.info, Node: Adding another Service to NSS, Next: NSS Module Function Internals, Prev: Extending NSS, Up: Extending NSS
  3629. 29.4.1 Adding another Service to NSS
  3630. ------------------------------------
  3631. The sources for a new service need not (and should not) be part of the
  3632. GNU C Library itself. The developer retains complete control over the
  3633. sources and its development. The links between the C library and the
  3634. new service module consists solely of the interface functions.
  3635. Each module is designed following a specific interface specification.
  3636. For now the version is 2 (the interface in version 1 was not adequate)
  3637. and this manifests in the version number of the shared library object of
  3638. the NSS modules: they have the extension ‘.2’. If the interface changes
  3639. again in an incompatible way, this number will be increased. Modules
  3640. using the old interface will still be usable.
  3641. Developers of a new service will have to make sure that their module
  3642. is created using the correct interface number. This means the file
  3643. itself must have the correct name and on ELF systems the “soname”
  3644. (Shared Object Name) must also have this number. Building a module from
  3645. a bunch of object files on an ELF system using GNU CC could be done like
  3646. this:
  3647. gcc -shared -o libnss_NAME.so.2 -Wl,-soname,libnss_NAME.so.2 OBJECTS
  3648. *note Options for Linking: (gcc)Link Options, to learn more about this
  3649. command line.
  3650. To use the new module the library must be able to find it. This can
  3651. be achieved by using options for the dynamic linker so that it will
  3652. search the directory where the binary is placed. For an ELF system this
  3653. could be done by adding the wanted directory to the value of
  3654. ‘LD_LIBRARY_PATH’.
  3655. But this is not always possible since some programs (those which run
  3656. under IDs which do not belong to the user) ignore this variable.
  3657. Therefore the stable version of the module should be placed into a
  3658. directory which is searched by the dynamic linker. Normally this should
  3659. be the directory ‘$prefix/lib’, where ‘$prefix’ corresponds to the value
  3660. given to configure using the ‘--prefix’ option. But be careful: this
  3661. should only be done if it is clear the module does not cause any harm.
  3662. System administrators should be careful.
  3663. 
  3664. File: libc.info, Node: NSS Module Function Internals, Prev: Adding another Service to NSS, Up: Extending NSS
  3665. 29.4.2 Internals of the NSS Module Functions
  3666. --------------------------------------------
  3667. Until now we only provided the syntactic interface for the functions in
  3668. the NSS module. In fact there is not much more we can say since the
  3669. implementation obviously is different for each function. But a few
  3670. general rules must be followed by all functions.
  3671. In fact there are four kinds of different functions which may appear
  3672. in the interface. All derive from the traditional ones for system
  3673. databases. DB in the following table is normally an abbreviation for
  3674. the database (e.g., it is ‘pw’ for the user database).
  3675. ‘enum nss_status _nss_DATABASE_setDBent (void)’
  3676. This function prepares the service for following operations. For a
  3677. simple file based lookup this means files could be opened, for
  3678. other services this function simply is a noop.
  3679. One special case for this function is that it takes an additional
  3680. argument for some DATABASEs (i.e., the interface is ‘int setDBent
  3681. (int)’). *note Host Names::, which describes the ‘sethostent’
  3682. function.
  3683. The return value should be NSS_STATUS_SUCCESS or according to the
  3684. table above in case of an error (*note NSS Modules Interface::).
  3685. ‘enum nss_status _nss_DATABASE_endDBent (void)’
  3686. This function simply closes all files which are still open or
  3687. removes buffer caches. If there are no files or buffers to remove
  3688. this is again a simple noop.
  3689. There normally is no return value other than NSS_STATUS_SUCCESS.
  3690. ‘enum nss_status _nss_DATABASE_getDBent_r (STRUCTURE *result, char *buffer, size_t buflen, int *errnop)’
  3691. Since this function will be called several times in a row to
  3692. retrieve one entry after the other it must keep some kind of state.
  3693. But this also means the functions are not really reentrant. They
  3694. are reentrant only in that simultaneous calls to this function will
  3695. not try to write the retrieved data in the same place (as it would
  3696. be the case for the non-reentrant functions); instead, it writes to
  3697. the structure pointed to by the RESULT parameter. But the calls
  3698. share a common state and in the case of a file access this means
  3699. they return neighboring entries in the file.
  3700. The buffer of length BUFLEN pointed to by BUFFER can be used for
  3701. storing some additional data for the result. It is _not_
  3702. guaranteed that the same buffer will be passed for the next call of
  3703. this function. Therefore one must not misuse this buffer to save
  3704. some state information from one call to another.
  3705. Before the function returns with a failure code, the implementation
  3706. should store the value of the local ‘errno’ variable in the
  3707. variable pointed to be ERRNOP. This is important to guarantee the
  3708. module working in statically linked programs. The stored value
  3709. must not be zero.
  3710. As explained above this function could also have an additional last
  3711. argument. This depends on the database used; it happens only for
  3712. ‘host’ and ‘networks’.
  3713. The function shall return ‘NSS_STATUS_SUCCESS’ as long as there are
  3714. more entries. When the last entry was read it should return
  3715. ‘NSS_STATUS_NOTFOUND’. When the buffer given as an argument is too
  3716. small for the data to be returned ‘NSS_STATUS_TRYAGAIN’ should be
  3717. returned. When the service was not formerly initialized by a call
  3718. to ‘_nss_DATABASE_setDBent’ all return values allowed for this
  3719. function can also be returned here.
  3720. ‘enum nss_status _nss_DATABASE_getDBbyXX_r (PARAMS, STRUCTURE *result, char *buffer, size_t buflen, int *errnop)’
  3721. This function shall return the entry from the database which is
  3722. addressed by the PARAMS. The type and number of these arguments
  3723. vary. It must be individually determined by looking to the
  3724. user-level interface functions. All arguments given to the
  3725. non-reentrant version are here described by PARAMS.
  3726. The result must be stored in the structure pointed to by RESULT.
  3727. If there are additional data to return (say strings, where the
  3728. RESULT structure only contains pointers) the function must use the
  3729. BUFFER of length BUFLEN. There must not be any references to
  3730. non-constant global data.
  3731. The implementation of this function should honor the STAYOPEN flag
  3732. set by the ‘setDBent’ function whenever this makes sense.
  3733. Before the function returns, the implementation should store the
  3734. value of the local ‘errno’ variable in the variable pointed to by
  3735. ERRNOP. This is important to guarantee the module works in
  3736. statically linked programs.
  3737. Again, this function takes an additional last argument for the
  3738. ‘host’ and ‘networks’ database.
  3739. The return value should as always follow the rules given above
  3740. (*note NSS Modules Interface::).
  3741. 
  3742. File: libc.info, Node: Users and Groups, Next: System Management, Prev: Name Service Switch, Up: Top
  3743. 30 Users and Groups
  3744. *******************
  3745. Every user who can log in on the system is identified by a unique number
  3746. called the “user ID”. Each process has an effective user ID which says
  3747. which user’s access permissions it has.
  3748. Users are classified into “groups” for access control purposes. Each
  3749. process has one or more “group ID values” which say which groups the
  3750. process can use for access to files.
  3751. The effective user and group IDs of a process collectively form its
  3752. “persona”. This determines which files the process can access.
  3753. Normally, a process inherits its persona from the parent process, but
  3754. under special circumstances a process can change its persona and thus
  3755. change its access permissions.
  3756. Each file in the system also has a user ID and a group ID. Access
  3757. control works by comparing the user and group IDs of the file with those
  3758. of the running process.
  3759. The system keeps a database of all the registered users, and another
  3760. database of all the defined groups. There are library functions you can
  3761. use to examine these databases.
  3762. * Menu:
  3763. * User and Group IDs:: Each user has a unique numeric ID;
  3764. likewise for groups.
  3765. * Process Persona:: The user IDs and group IDs of a process.
  3766. * Why Change Persona:: Why a program might need to change
  3767. its user and/or group IDs.
  3768. * How Change Persona:: Changing the user and group IDs.
  3769. * Reading Persona:: How to examine the user and group IDs.
  3770. * Setting User ID:: Functions for setting the user ID.
  3771. * Setting Groups:: Functions for setting the group IDs.
  3772. * Enable/Disable Setuid:: Turning setuid access on and off.
  3773. * Setuid Program Example:: The pertinent parts of one sample program.
  3774. * Tips for Setuid:: How to avoid granting unlimited access.
  3775. * Who Logged In:: Getting the name of the user who logged in,
  3776. or of the real user ID of the current process.
  3777. * User Accounting Database:: Keeping information about users and various
  3778. actions in databases.
  3779. * User Database:: Functions and data structures for
  3780. accessing the user database.
  3781. * Group Database:: Functions and data structures for
  3782. accessing the group database.
  3783. * Database Example:: Example program showing the use of database
  3784. inquiry functions.
  3785. * Netgroup Database:: Functions for accessing the netgroup database.
  3786. 
  3787. File: libc.info, Node: User and Group IDs, Next: Process Persona, Up: Users and Groups
  3788. 30.1 User and Group IDs
  3789. =======================
  3790. Each user account on a computer system is identified by a “user name”
  3791. (or “login name”) and “user ID”. Normally, each user name has a unique
  3792. user ID, but it is possible for several login names to have the same
  3793. user ID. The user names and corresponding user IDs are stored in a data
  3794. base which you can access as described in *note User Database::.
  3795. Users are classified in “groups”. Each user name belongs to one
  3796. “default group” and may also belong to any number of “supplementary
  3797. groups”. Users who are members of the same group can share resources
  3798. (such as files) that are not accessible to users who are not a member of
  3799. that group. Each group has a “group name” and “group ID”. *Note Group
  3800. Database::, for how to find information about a group ID or group name.
  3801. 
  3802. File: libc.info, Node: Process Persona, Next: Why Change Persona, Prev: User and Group IDs, Up: Users and Groups
  3803. 30.2 The Persona of a Process
  3804. =============================
  3805. At any time, each process has an “effective user ID”, a “effective group
  3806. ID”, and a set of “supplementary group IDs”. These IDs determine the
  3807. privileges of the process. They are collectively called the “persona”
  3808. of the process, because they determine “who it is” for purposes of
  3809. access control.
  3810. Your login shell starts out with a persona which consists of your
  3811. user ID, your default group ID, and your supplementary group IDs (if you
  3812. are in more than one group). In normal circumstances, all your other
  3813. processes inherit these values.
  3814. A process also has a “real user ID” which identifies the user who
  3815. created the process, and a “real group ID” which identifies that user’s
  3816. default group. These values do not play a role in access control, so we
  3817. do not consider them part of the persona. But they are also important.
  3818. Both the real and effective user ID can be changed during the
  3819. lifetime of a process. *Note Why Change Persona::.
  3820. For details on how a process’s effective user ID and group IDs affect
  3821. its permission to access files, see *note Access Permission::.
  3822. The effective user ID of a process also controls permissions for
  3823. sending signals using the ‘kill’ function. *Note Signaling Another
  3824. Process::.
  3825. Finally, there are many operations which can only be performed by a
  3826. process whose effective user ID is zero. A process with this user ID is
  3827. a “privileged process”. Commonly the user name ‘root’ is associated
  3828. with user ID 0, but there may be other user names with this ID.
  3829. 
  3830. File: libc.info, Node: Why Change Persona, Next: How Change Persona, Prev: Process Persona, Up: Users and Groups
  3831. 30.3 Why Change the Persona of a Process?
  3832. =========================================
  3833. The most obvious situation where it is necessary for a process to change
  3834. its user and/or group IDs is the ‘login’ program. When ‘login’ starts
  3835. running, its user ID is ‘root’. Its job is to start a shell whose user
  3836. and group IDs are those of the user who is logging in. (To accomplish
  3837. this fully, ‘login’ must set the real user and group IDs as well as its
  3838. persona. But this is a special case.)
  3839. The more common case of changing persona is when an ordinary user
  3840. program needs access to a resource that wouldn’t ordinarily be
  3841. accessible to the user actually running it.
  3842. For example, you may have a file that is controlled by your program
  3843. but that shouldn’t be read or modified directly by other users, either
  3844. because it implements some kind of locking protocol, or because you want
  3845. to preserve the integrity or privacy of the information it contains.
  3846. This kind of restricted access can be implemented by having the program
  3847. change its effective user or group ID to match that of the resource.
  3848. Thus, imagine a game program that saves scores in a file. The game
  3849. program itself needs to be able to update this file no matter who is
  3850. running it, but if users can write the file without going through the
  3851. game, they can give themselves any scores they like. Some people
  3852. consider this undesirable, or even reprehensible. It can be prevented
  3853. by creating a new user ID and login name (say, ‘games’) to own the
  3854. scores file, and make the file writable only by this user. Then, when
  3855. the game program wants to update this file, it can change its effective
  3856. user ID to be that for ‘games’. In effect, the program must adopt the
  3857. persona of ‘games’ so it can write to the scores file.
  3858. 
  3859. File: libc.info, Node: How Change Persona, Next: Reading Persona, Prev: Why Change Persona, Up: Users and Groups
  3860. 30.4 How an Application Can Change Persona
  3861. ==========================================
  3862. The ability to change the persona of a process can be a source of
  3863. unintentional privacy violations, or even intentional abuse. Because of
  3864. the potential for problems, changing persona is restricted to special
  3865. circumstances.
  3866. You can’t arbitrarily set your user ID or group ID to anything you
  3867. want; only privileged processes can do that. Instead, the normal way
  3868. for a program to change its persona is that it has been set up in
  3869. advance to change to a particular user or group. This is the function
  3870. of the setuid and setgid bits of a file’s access mode. *Note Permission
  3871. Bits::.
  3872. When the setuid bit of an executable file is on, executing that file
  3873. gives the process a third user ID: the “file user ID”. This ID is set to
  3874. the owner ID of the file. The system then changes the effective user ID
  3875. to the file user ID. The real user ID remains as it was. Likewise, if
  3876. the setgid bit is on, the process is given a “file group ID” equal to
  3877. the group ID of the file, and its effective group ID is changed to the
  3878. file group ID.
  3879. If a process has a file ID (user or group), then it can at any time
  3880. change its effective ID to its real ID and back to its file ID. Programs
  3881. use this feature to relinquish their special privileges except when they
  3882. actually need them. This makes it less likely that they can be tricked
  3883. into doing something inappropriate with their privileges.
  3884. *Portability Note:* Older systems do not have file IDs. To determine
  3885. if a system has this feature, you can test the compiler define
  3886. ‘_POSIX_SAVED_IDS’. (In the POSIX standard, file IDs are known as saved
  3887. IDs.)
  3888. *Note File Attributes::, for a more general discussion of file modes
  3889. and accessibility.
  3890. 
  3891. File: libc.info, Node: Reading Persona, Next: Setting User ID, Prev: How Change Persona, Up: Users and Groups
  3892. 30.5 Reading the Persona of a Process
  3893. =====================================
  3894. Here are detailed descriptions of the functions for reading the user and
  3895. group IDs of a process, both real and effective. To use these
  3896. facilities, you must include the header files ‘sys/types.h’ and
  3897. ‘unistd.h’.
  3898. -- Data Type: uid_t
  3899. This is an integer data type used to represent user IDs. In the
  3900. GNU C Library, this is an alias for ‘unsigned int’.
  3901. -- Data Type: gid_t
  3902. This is an integer data type used to represent group IDs. In the
  3903. GNU C Library, this is an alias for ‘unsigned int’.
  3904. -- Function: uid_t getuid (void)
  3905. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3906. Concepts::.
  3907. The ‘getuid’ function returns the real user ID of the process.
  3908. -- Function: gid_t getgid (void)
  3909. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3910. Concepts::.
  3911. The ‘getgid’ function returns the real group ID of the process.
  3912. -- Function: uid_t geteuid (void)
  3913. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3914. Concepts::.
  3915. The ‘geteuid’ function returns the effective user ID of the
  3916. process.
  3917. -- Function: gid_t getegid (void)
  3918. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3919. Concepts::.
  3920. The ‘getegid’ function returns the effective group ID of the
  3921. process.
  3922. -- Function: int getgroups (int COUNT, gid_t *GROUPS)
  3923. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3924. Concepts::.
  3925. The ‘getgroups’ function is used to inquire about the supplementary
  3926. group IDs of the process. Up to COUNT of these group IDs are
  3927. stored in the array GROUPS; the return value from the function is
  3928. the number of group IDs actually stored. If COUNT is smaller than
  3929. the total number of supplementary group IDs, then ‘getgroups’
  3930. returns a value of ‘-1’ and ‘errno’ is set to ‘EINVAL’.
  3931. If COUNT is zero, then ‘getgroups’ just returns the total number of
  3932. supplementary group IDs. On systems that do not support
  3933. supplementary groups, this will always be zero.
  3934. Here’s how to use ‘getgroups’ to read all the supplementary group
  3935. IDs:
  3936. gid_t *
  3937. read_all_groups (void)
  3938. {
  3939. int ngroups = getgroups (0, NULL);
  3940. gid_t *groups
  3941. = (gid_t *) xmalloc (ngroups * sizeof (gid_t));
  3942. int val = getgroups (ngroups, groups);
  3943. if (val < 0)
  3944. {
  3945. free (groups);
  3946. return NULL;
  3947. }
  3948. return groups;
  3949. }
  3950. 
  3951. File: libc.info, Node: Setting User ID, Next: Setting Groups, Prev: Reading Persona, Up: Users and Groups
  3952. 30.6 Setting the User ID
  3953. ========================
  3954. This section describes the functions for altering the user ID (real
  3955. and/or effective) of a process. To use these facilities, you must
  3956. include the header files ‘sys/types.h’ and ‘unistd.h’.
  3957. -- Function: int seteuid (uid_t NEWEUID)
  3958. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3959. POSIX Safety Concepts::.
  3960. This function sets the effective user ID of a process to NEWEUID,
  3961. provided that the process is allowed to change its effective user
  3962. ID. A privileged process (effective user ID zero) can change its
  3963. effective user ID to any legal value. An unprivileged process with
  3964. a file user ID can change its effective user ID to its real user ID
  3965. or to its file user ID. Otherwise, a process may not change its
  3966. effective user ID at all.
  3967. The ‘seteuid’ function returns a value of ‘0’ to indicate
  3968. successful completion, and a value of ‘-1’ to indicate an error.
  3969. The following ‘errno’ error conditions are defined for this
  3970. function:
  3971. ‘EINVAL’
  3972. The value of the NEWEUID argument is invalid.
  3973. ‘EPERM’
  3974. The process may not change to the specified ID.
  3975. Older systems (those without the ‘_POSIX_SAVED_IDS’ feature) do not
  3976. have this function.
  3977. -- Function: int setuid (uid_t NEWUID)
  3978. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3979. POSIX Safety Concepts::.
  3980. If the calling process is privileged, this function sets both the
  3981. real and effective user IDs of the process to NEWUID. It also
  3982. deletes the file user ID of the process, if any. NEWUID may be any
  3983. legal value. (Once this has been done, there is no way to recover
  3984. the old effective user ID.)
  3985. If the process is not privileged, and the system supports the
  3986. ‘_POSIX_SAVED_IDS’ feature, then this function behaves like
  3987. ‘seteuid’.
  3988. The return values and error conditions are the same as for
  3989. ‘seteuid’.
  3990. -- Function: int setreuid (uid_t RUID, uid_t EUID)
  3991. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3992. POSIX Safety Concepts::.
  3993. This function sets the real user ID of the process to RUID and the
  3994. effective user ID to EUID. If RUID is ‘-1’, it means not to change
  3995. the real user ID; likewise if EUID is ‘-1’, it means not to change
  3996. the effective user ID.
  3997. The ‘setreuid’ function exists for compatibility with 4.3 BSD Unix,
  3998. which does not support file IDs. You can use this function to swap
  3999. the effective and real user IDs of the process. (Privileged
  4000. processes are not limited to this particular usage.) If file IDs
  4001. are supported, you should use that feature instead of this
  4002. function. *Note Enable/Disable Setuid::.
  4003. The return value is ‘0’ on success and ‘-1’ on failure. The
  4004. following ‘errno’ error conditions are defined for this function:
  4005. ‘EPERM’
  4006. The process does not have the appropriate privileges; you do
  4007. not have permission to change to the specified ID.
  4008. 
  4009. File: libc.info, Node: Setting Groups, Next: Enable/Disable Setuid, Prev: Setting User ID, Up: Users and Groups
  4010. 30.7 Setting the Group IDs
  4011. ==========================
  4012. This section describes the functions for altering the group IDs (real
  4013. and effective) of a process. To use these facilities, you must include
  4014. the header files ‘sys/types.h’ and ‘unistd.h’.
  4015. -- Function: int setegid (gid_t NEWGID)
  4016. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  4017. POSIX Safety Concepts::.
  4018. This function sets the effective group ID of the process to NEWGID,
  4019. provided that the process is allowed to change its group ID. Just
  4020. as with ‘seteuid’, if the process is privileged it may change its
  4021. effective group ID to any value; if it isn’t, but it has a file
  4022. group ID, then it may change to its real group ID or file group ID;
  4023. otherwise it may not change its effective group ID.
  4024. Note that a process is only privileged if its effective _user_ ID
  4025. is zero. The effective group ID only affects access permissions.
  4026. The return values and error conditions for ‘setegid’ are the same
  4027. as those for ‘seteuid’.
  4028. This function is only present if ‘_POSIX_SAVED_IDS’ is defined.
  4029. -- Function: int setgid (gid_t NEWGID)
  4030. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  4031. POSIX Safety Concepts::.
  4032. This function sets both the real and effective group ID of the
  4033. process to NEWGID, provided that the process is privileged. It
  4034. also deletes the file group ID, if any.
  4035. If the process is not privileged, then ‘setgid’ behaves like
  4036. ‘setegid’.
  4037. The return values and error conditions for ‘setgid’ are the same as
  4038. those for ‘seteuid’.
  4039. -- Function: int setregid (gid_t RGID, gid_t EGID)
  4040. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  4041. POSIX Safety Concepts::.
  4042. This function sets the real group ID of the process to RGID and the
  4043. effective group ID to EGID. If RGID is ‘-1’, it means not to
  4044. change the real group ID; likewise if EGID is ‘-1’, it means not to
  4045. change the effective group ID.
  4046. The ‘setregid’ function is provided for compatibility with 4.3 BSD
  4047. Unix, which does not support file IDs. You can use this function
  4048. to swap the effective and real group IDs of the process.
  4049. (Privileged processes are not limited to this usage.) If file IDs
  4050. are supported, you should use that feature instead of using this
  4051. function. *Note Enable/Disable Setuid::.
  4052. The return values and error conditions for ‘setregid’ are the same
  4053. as those for ‘setreuid’.
  4054. ‘setuid’ and ‘setgid’ behave differently depending on whether the
  4055. effective user ID at the time is zero. If it is not zero, they behave
  4056. like ‘seteuid’ and ‘setegid’. If it is, they change both effective and
  4057. real IDs and delete the file ID. To avoid confusion, we recommend you
  4058. always use ‘seteuid’ and ‘setegid’ except when you know the effective
  4059. user ID is zero and your intent is to change the persona permanently.
  4060. This case is rare—most of the programs that need it, such as ‘login’ and
  4061. ‘su’, have already been written.
  4062. Note that if your program is setuid to some user other than ‘root’,
  4063. there is no way to drop privileges permanently.
  4064. The system also lets privileged processes change their supplementary
  4065. group IDs. To use ‘setgroups’ or ‘initgroups’, your programs should
  4066. include the header file ‘grp.h’.
  4067. -- Function: int setgroups (size_t COUNT, const gid_t *GROUPS)
  4068. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  4069. POSIX Safety Concepts::.
  4070. This function sets the process’s supplementary group IDs. It can
  4071. only be called from privileged processes. The COUNT argument
  4072. specifies the number of group IDs in the array GROUPS.
  4073. This function returns ‘0’ if successful and ‘-1’ on error. The
  4074. following ‘errno’ error conditions are defined for this function:
  4075. ‘EPERM’
  4076. The calling process is not privileged.
  4077. -- Function: int initgroups (const char *USER, gid_t GROUP)
  4078. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4079. AC-Unsafe corrupt mem fd lock | *Note POSIX Safety Concepts::.
  4080. The ‘initgroups’ function sets the process’s supplementary group
  4081. IDs to be the normal default for the user name USER. The group
  4082. GROUP is automatically included.
  4083. This function works by scanning the group database for all the
  4084. groups USER belongs to. It then calls ‘setgroups’ with the list it
  4085. has constructed.
  4086. The return values and error conditions are the same as for
  4087. ‘setgroups’.
  4088. If you are interested in the groups a particular user belongs to, but
  4089. do not want to change the process’s supplementary group IDs, you can use
  4090. ‘getgrouplist’. To use ‘getgrouplist’, your programs should include the
  4091. header file ‘grp.h’.
  4092. -- Function: int getgrouplist (const char *USER, gid_t GROUP, gid_t
  4093. *GROUPS, int *NGROUPS)
  4094. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4095. AC-Unsafe corrupt mem fd lock | *Note POSIX Safety Concepts::.
  4096. The ‘getgrouplist’ function scans the group database for all the
  4097. groups USER belongs to. Up to *NGROUPS group IDs corresponding to
  4098. these groups are stored in the array GROUPS; the return value from
  4099. the function is the number of group IDs actually stored. If
  4100. *NGROUPS is smaller than the total number of groups found, then
  4101. ‘getgrouplist’ returns a value of ‘-1’ and stores the actual number
  4102. of groups in *NGROUPS. The group GROUP is automatically included
  4103. in the list of groups returned by ‘getgrouplist’.
  4104. Here’s how to use ‘getgrouplist’ to read all supplementary groups
  4105. for USER:
  4106. gid_t *
  4107. supplementary_groups (char *user)
  4108. {
  4109. int ngroups = 16;
  4110. gid_t *groups
  4111. = (gid_t *) xmalloc (ngroups * sizeof (gid_t));
  4112. struct passwd *pw = getpwnam (user);
  4113. if (pw == NULL)
  4114. return NULL;
  4115. if (getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups) < 0)
  4116. {
  4117. groups = xrealloc (ngroups * sizeof (gid_t));
  4118. getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups);
  4119. }
  4120. return groups;
  4121. }
  4122. 
  4123. File: libc.info, Node: Enable/Disable Setuid, Next: Setuid Program Example, Prev: Setting Groups, Up: Users and Groups
  4124. 30.8 Enabling and Disabling Setuid Access
  4125. =========================================
  4126. A typical setuid program does not need its special access all of the
  4127. time. It’s a good idea to turn off this access when it isn’t needed, so
  4128. it can’t possibly give unintended access.
  4129. If the system supports the ‘_POSIX_SAVED_IDS’ feature, you can
  4130. accomplish this with ‘seteuid’. When the game program starts, its real
  4131. user ID is ‘jdoe’, its effective user ID is ‘games’, and its saved user
  4132. ID is also ‘games’. The program should record both user ID values once
  4133. at the beginning, like this:
  4134. user_user_id = getuid ();
  4135. game_user_id = geteuid ();
  4136. Then it can turn off game file access with
  4137. seteuid (user_user_id);
  4138. and turn it on with
  4139. seteuid (game_user_id);
  4140. Throughout this process, the real user ID remains ‘jdoe’ and the file
  4141. user ID remains ‘games’, so the program can always set its effective
  4142. user ID to either one.
  4143. On other systems that don’t support file user IDs, you can turn
  4144. setuid access on and off by using ‘setreuid’ to swap the real and
  4145. effective user IDs of the process, as follows:
  4146. setreuid (geteuid (), getuid ());
  4147. This special case is always allowed—it cannot fail.
  4148. Why does this have the effect of toggling the setuid access? Suppose
  4149. a game program has just started, and its real user ID is ‘jdoe’ while
  4150. its effective user ID is ‘games’. In this state, the game can write the
  4151. scores file. If it swaps the two uids, the real becomes ‘games’ and the
  4152. effective becomes ‘jdoe’; now the program has only ‘jdoe’ access.
  4153. Another swap brings ‘games’ back to the effective user ID and restores
  4154. access to the scores file.
  4155. In order to handle both kinds of systems, test for the saved user ID
  4156. feature with a preprocessor conditional, like this:
  4157. #ifdef _POSIX_SAVED_IDS
  4158. seteuid (user_user_id);
  4159. #else
  4160. setreuid (geteuid (), getuid ());
  4161. #endif
  4162. 
  4163. File: libc.info, Node: Setuid Program Example, Next: Tips for Setuid, Prev: Enable/Disable Setuid, Up: Users and Groups
  4164. 30.9 Setuid Program Example
  4165. ===========================
  4166. Here’s an example showing how to set up a program that changes its
  4167. effective user ID.
  4168. This is part of a game program called ‘caber-toss’ that manipulates a
  4169. file ‘scores’ that should be writable only by the game program itself.
  4170. The program assumes that its executable file will be installed with the
  4171. setuid bit set and owned by the same user as the ‘scores’ file.
  4172. Typically, a system administrator will set up an account like ‘games’
  4173. for this purpose.
  4174. The executable file is given mode ‘4755’, so that doing an ‘ls -l’ on
  4175. it produces output like:
  4176. -rwsr-xr-x 1 games 184422 Jul 30 15:17 caber-toss
  4177. The setuid bit shows up in the file modes as the ‘s’.
  4178. The scores file is given mode ‘644’, and doing an ‘ls -l’ on it
  4179. shows:
  4180. -rw-r--r-- 1 games 0 Jul 31 15:33 scores
  4181. Here are the parts of the program that show how to set up the changed
  4182. user ID. This program is conditionalized so that it makes use of the
  4183. file IDs feature if it is supported, and otherwise uses ‘setreuid’ to
  4184. swap the effective and real user IDs.
  4185. #include <stdio.h>
  4186. #include <sys/types.h>
  4187. #include <unistd.h>
  4188. #include <stdlib.h>
  4189. /* Remember the effective and real UIDs. */
  4190. static uid_t euid, ruid;
  4191. /* Restore the effective UID to its original value. */
  4192. void
  4193. do_setuid (void)
  4194. {
  4195. int status;
  4196. #ifdef _POSIX_SAVED_IDS
  4197. status = seteuid (euid);
  4198. #else
  4199. status = setreuid (ruid, euid);
  4200. #endif
  4201. if (status < 0) {
  4202. fprintf (stderr, "Couldn't set uid.\n");
  4203. exit (status);
  4204. }
  4205. }
  4206. /* Set the effective UID to the real UID. */
  4207. void
  4208. undo_setuid (void)
  4209. {
  4210. int status;
  4211. #ifdef _POSIX_SAVED_IDS
  4212. status = seteuid (ruid);
  4213. #else
  4214. status = setreuid (euid, ruid);
  4215. #endif
  4216. if (status < 0) {
  4217. fprintf (stderr, "Couldn't set uid.\n");
  4218. exit (status);
  4219. }
  4220. }
  4221. /* Main program. */
  4222. int
  4223. main (void)
  4224. {
  4225. /* Remember the real and effective user IDs. */
  4226. ruid = getuid ();
  4227. euid = geteuid ();
  4228. undo_setuid ();
  4229. /* Do the game and record the score. */
  4230. ...
  4231. }
  4232. Notice how the first thing the ‘main’ function does is to set the
  4233. effective user ID back to the real user ID. This is so that any other
  4234. file accesses that are performed while the user is playing the game use
  4235. the real user ID for determining permissions. Only when the program
  4236. needs to open the scores file does it switch back to the file user ID,
  4237. like this:
  4238. /* Record the score. */
  4239. int
  4240. record_score (int score)
  4241. {
  4242. FILE *stream;
  4243. char *myname;
  4244. /* Open the scores file. */
  4245. do_setuid ();
  4246. stream = fopen (SCORES_FILE, "a");
  4247. undo_setuid ();
  4248. /* Write the score to the file. */
  4249. if (stream)
  4250. {
  4251. myname = cuserid (NULL);
  4252. if (score < 0)
  4253. fprintf (stream, "%10s: Couldn't lift the caber.\n", myname);
  4254. else
  4255. fprintf (stream, "%10s: %d feet.\n", myname, score);
  4256. fclose (stream);
  4257. return 0;
  4258. }
  4259. else
  4260. return -1;
  4261. }
  4262. 
  4263. File: libc.info, Node: Tips for Setuid, Next: Who Logged In, Prev: Setuid Program Example, Up: Users and Groups
  4264. 30.10 Tips for Writing Setuid Programs
  4265. ======================================
  4266. It is easy for setuid programs to give the user access that isn’t
  4267. intended—in fact, if you want to avoid this, you need to be careful.
  4268. Here are some guidelines for preventing unintended access and minimizing
  4269. its consequences when it does occur:
  4270. • Don’t have ‘setuid’ programs with privileged user IDs such as
  4271. ‘root’ unless it is absolutely necessary. If the resource is
  4272. specific to your particular program, it’s better to define a new,
  4273. nonprivileged user ID or group ID just to manage that resource.
  4274. It’s better if you can write your program to use a special group
  4275. than a special user.
  4276. • Be cautious about using the ‘exec’ functions in combination with
  4277. changing the effective user ID. Don’t let users of your program
  4278. execute arbitrary programs under a changed user ID. Executing a
  4279. shell is especially bad news. Less obviously, the ‘execlp’ and
  4280. ‘execvp’ functions are a potential risk (since the program they
  4281. execute depends on the user’s ‘PATH’ environment variable).
  4282. If you must ‘exec’ another program under a changed ID, specify an
  4283. absolute file name (*note File Name Resolution::) for the
  4284. executable, and make sure that the protections on that executable
  4285. and _all_ containing directories are such that ordinary users
  4286. cannot replace it with some other program.
  4287. You should also check the arguments passed to the program to make
  4288. sure they do not have unexpected effects. Likewise, you should
  4289. examine the environment variables. Decide which arguments and
  4290. variables are safe, and reject all others.
  4291. You should never use ‘system’ in a privileged program, because it
  4292. invokes a shell.
  4293. • Only use the user ID controlling the resource in the part of the
  4294. program that actually uses that resource. When you’re finished
  4295. with it, restore the effective user ID back to the actual user’s
  4296. user ID. *Note Enable/Disable Setuid::.
  4297. • If the ‘setuid’ part of your program needs to access other files
  4298. besides the controlled resource, it should verify that the real
  4299. user would ordinarily have permission to access those files. You
  4300. can use the ‘access’ function (*note Access Permission::) to check
  4301. this; it uses the real user and group IDs, rather than the
  4302. effective IDs.
  4303. 
  4304. File: libc.info, Node: Who Logged In, Next: User Accounting Database, Prev: Tips for Setuid, Up: Users and Groups
  4305. 30.11 Identifying Who Logged In
  4306. ===============================
  4307. You can use the functions listed in this section to determine the login
  4308. name of the user who is running a process, and the name of the user who
  4309. logged in the current session. See also the function ‘getuid’ and
  4310. friends (*note Reading Persona::). How this information is collected by
  4311. the system and how to control/add/remove information from the background
  4312. storage is described in *note User Accounting Database::.
  4313. The ‘getlogin’ function is declared in ‘unistd.h’, while ‘cuserid’
  4314. and ‘L_cuserid’ are declared in ‘stdio.h’.
  4315. -- Function: char * getlogin (void)
  4316. Preliminary: | MT-Unsafe race:getlogin race:utent sig:ALRM timer
  4317. locale | AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock
  4318. fd mem | *Note POSIX Safety Concepts::.
  4319. The ‘getlogin’ function returns a pointer to a string containing
  4320. the name of the user logged in on the controlling terminal of the
  4321. process, or a null pointer if this information cannot be
  4322. determined. The string is statically allocated and might be
  4323. overwritten on subsequent calls to this function or to ‘cuserid’.
  4324. -- Function: char * cuserid (char *STRING)
  4325. Preliminary: | MT-Unsafe race:cuserid/!string locale | AS-Unsafe
  4326. dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note
  4327. POSIX Safety Concepts::.
  4328. The ‘cuserid’ function returns a pointer to a string containing a
  4329. user name associated with the effective ID of the process. If
  4330. STRING is not a null pointer, it should be an array that can hold
  4331. at least ‘L_cuserid’ characters; the string is returned in this
  4332. array. Otherwise, a pointer to a string in a static area is
  4333. returned. This string is statically allocated and might be
  4334. overwritten on subsequent calls to this function or to ‘getlogin’.
  4335. The use of this function is deprecated since it is marked to be
  4336. withdrawn in XPG4.2 and has already been removed from newer
  4337. revisions of POSIX.1.
  4338. -- Macro: int L_cuserid
  4339. An integer constant that indicates how long an array you might need
  4340. to store a user name.
  4341. These functions let your program identify positively the user who is
  4342. running or the user who logged in this session. (These can differ when
  4343. setuid programs are involved; see *note Process Persona::.) The user
  4344. cannot do anything to fool these functions.
  4345. For most purposes, it is more useful to use the environment variable
  4346. ‘LOGNAME’ to find out who the user is. This is more flexible precisely
  4347. because the user can set ‘LOGNAME’ arbitrarily. *Note Standard
  4348. Environment::.
  4349. 
  4350. File: libc.info, Node: User Accounting Database, Next: User Database, Prev: Who Logged In, Up: Users and Groups
  4351. 30.12 The User Accounting Database
  4352. ==================================
  4353. Most Unix-like operating systems keep track of logged in users by
  4354. maintaining a user accounting database. This user accounting database
  4355. stores for each terminal, who has logged on, at what time, the process
  4356. ID of the user’s login shell, etc., etc., but also stores information
  4357. about the run level of the system, the time of the last system reboot,
  4358. and possibly more.
  4359. The user accounting database typically lives in ‘/etc/utmp’,
  4360. ‘/var/adm/utmp’ or ‘/var/run/utmp’. However, these files should *never*
  4361. be accessed directly. For reading information from and writing
  4362. information to the user accounting database, the functions described in
  4363. this section should be used.
  4364. * Menu:
  4365. * Manipulating the Database:: Scanning and modifying the user
  4366. accounting database.
  4367. * XPG Functions:: A standardized way for doing the same thing.
  4368. * Logging In and Out:: Functions from BSD that modify the user
  4369. accounting database.
  4370. 
  4371. File: libc.info, Node: Manipulating the Database, Next: XPG Functions, Up: User Accounting Database
  4372. 30.12.1 Manipulating the User Accounting Database
  4373. -------------------------------------------------
  4374. These functions and the corresponding data structures are declared in
  4375. the header file ‘utmp.h’.
  4376. -- Data Type: struct exit_status
  4377. The ‘exit_status’ data structure is used to hold information about
  4378. the exit status of processes marked as ‘DEAD_PROCESS’ in the user
  4379. accounting database.
  4380. ‘short int e_termination’
  4381. The exit status of the process.
  4382. ‘short int e_exit’
  4383. The exit status of the process.
  4384. -- Data Type: struct utmp
  4385. The ‘utmp’ data structure is used to hold information about entries
  4386. in the user accounting database. On GNU systems it has the
  4387. following members:
  4388. ‘short int ut_type’
  4389. Specifies the type of login; one of ‘EMPTY’, ‘RUN_LVL’,
  4390. ‘BOOT_TIME’, ‘OLD_TIME’, ‘NEW_TIME’, ‘INIT_PROCESS’,
  4391. ‘LOGIN_PROCESS’, ‘USER_PROCESS’, ‘DEAD_PROCESS’ or
  4392. ‘ACCOUNTING’.
  4393. ‘pid_t ut_pid’
  4394. The process ID number of the login process.
  4395. ‘char ut_line[]’
  4396. The device name of the tty (without ‘/dev/’).
  4397. ‘char ut_id[]’
  4398. The inittab ID of the process.
  4399. ‘char ut_user[]’
  4400. The user’s login name.
  4401. ‘char ut_host[]’
  4402. The name of the host from which the user logged in.
  4403. ‘struct exit_status ut_exit’
  4404. The exit status of a process marked as ‘DEAD_PROCESS’.
  4405. ‘long ut_session’
  4406. The Session ID, used for windowing.
  4407. ‘struct timeval ut_tv’
  4408. Time the entry was made. For entries of type ‘OLD_TIME’ this
  4409. is the time when the system clock changed, and for entries of
  4410. type ‘NEW_TIME’ this is the time the system clock was set to.
  4411. ‘int32_t ut_addr_v6[4]’
  4412. The Internet address of a remote host.
  4413. The ‘ut_type’, ‘ut_pid’, ‘ut_id’, ‘ut_tv’, and ‘ut_host’ fields are
  4414. not available on all systems. Portable applications therefore should be
  4415. prepared for these situations. To help do this the ‘utmp.h’ header
  4416. provides macros ‘_HAVE_UT_TYPE’, ‘_HAVE_UT_PID’, ‘_HAVE_UT_ID’,
  4417. ‘_HAVE_UT_TV’, and ‘_HAVE_UT_HOST’ if the respective field is available.
  4418. The programmer can handle the situations by using ‘#ifdef’ in the
  4419. program code.
  4420. The following macros are defined for use as values for the ‘ut_type’
  4421. member of the ‘utmp’ structure. The values are integer constants.
  4422. ‘EMPTY’
  4423. This macro is used to indicate that the entry contains no valid
  4424. user accounting information.
  4425. ‘RUN_LVL’
  4426. This macro is used to identify the system’s runlevel.
  4427. ‘BOOT_TIME’
  4428. This macro is used to identify the time of system boot.
  4429. ‘OLD_TIME’
  4430. This macro is used to identify the time when the system clock
  4431. changed.
  4432. ‘NEW_TIME’
  4433. This macro is used to identify the time after the system clock
  4434. changed.
  4435. ‘INIT_PROCESS’
  4436. This macro is used to identify a process spawned by the init
  4437. process.
  4438. ‘LOGIN_PROCESS’
  4439. This macro is used to identify the session leader of a logged in
  4440. user.
  4441. ‘USER_PROCESS’
  4442. This macro is used to identify a user process.
  4443. ‘DEAD_PROCESS’
  4444. This macro is used to identify a terminated process.
  4445. ‘ACCOUNTING’
  4446. ???
  4447. The size of the ‘ut_line’, ‘ut_id’, ‘ut_user’ and ‘ut_host’ arrays
  4448. can be found using the ‘sizeof’ operator.
  4449. Many older systems have, instead of an ‘ut_tv’ member, an ‘ut_time’
  4450. member, usually of type ‘time_t’, for representing the time associated
  4451. with the entry. Therefore, for backwards compatibility only, ‘utmp.h’
  4452. defines ‘ut_time’ as an alias for ‘ut_tv.tv_sec’.
  4453. -- Function: void setutent (void)
  4454. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4455. lock fd | *Note POSIX Safety Concepts::.
  4456. This function opens the user accounting database to begin scanning
  4457. it. You can then call ‘getutent’, ‘getutid’ or ‘getutline’ to read
  4458. entries and ‘pututline’ to write entries.
  4459. If the database is already open, it resets the input to the
  4460. beginning of the database.
  4461. -- Function: struct utmp * getutent (void)
  4462. Preliminary: | MT-Unsafe init race:utent race:utentbuf sig:ALRM
  4463. timer | AS-Unsafe heap lock | AC-Unsafe lock fd mem | *Note POSIX
  4464. Safety Concepts::.
  4465. The ‘getutent’ function reads the next entry from the user
  4466. accounting database. It returns a pointer to the entry, which is
  4467. statically allocated and may be overwritten by subsequent calls to
  4468. ‘getutent’. You must copy the contents of the structure if you
  4469. wish to save the information or you can use the ‘getutent_r’
  4470. function which stores the data in a user-provided buffer.
  4471. A null pointer is returned in case no further entry is available.
  4472. -- Function: void endutent (void)
  4473. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4474. lock fd | *Note POSIX Safety Concepts::.
  4475. This function closes the user accounting database.
  4476. -- Function: struct utmp * getutid (const struct utmp *ID)
  4477. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4478. lock heap | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  4479. This function searches forward from the current point in the
  4480. database for an entry that matches ID. If the ‘ut_type’ member of
  4481. the ID structure is one of ‘RUN_LVL’, ‘BOOT_TIME’, ‘OLD_TIME’ or
  4482. ‘NEW_TIME’ the entries match if the ‘ut_type’ members are
  4483. identical. If the ‘ut_type’ member of the ID structure is
  4484. ‘INIT_PROCESS’, ‘LOGIN_PROCESS’, ‘USER_PROCESS’ or ‘DEAD_PROCESS’,
  4485. the entries match if the ‘ut_type’ member of the entry read from
  4486. the database is one of these four, and the ‘ut_id’ members match.
  4487. However if the ‘ut_id’ member of either the ID structure or the
  4488. entry read from the database is empty it checks if the ‘ut_line’
  4489. members match instead. If a matching entry is found, ‘getutid’
  4490. returns a pointer to the entry, which is statically allocated, and
  4491. may be overwritten by a subsequent call to ‘getutent’, ‘getutid’ or
  4492. ‘getutline’. You must copy the contents of the structure if you
  4493. wish to save the information.
  4494. A null pointer is returned in case the end of the database is
  4495. reached without a match.
  4496. The ‘getutid’ function may cache the last read entry. Therefore,
  4497. if you are using ‘getutid’ to search for multiple occurrences, it
  4498. is necessary to zero out the static data after each call.
  4499. Otherwise ‘getutid’ could just return a pointer to the same entry
  4500. over and over again.
  4501. -- Function: struct utmp * getutline (const struct utmp *LINE)
  4502. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4503. heap lock | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4504. This function searches forward from the current point in the
  4505. database until it finds an entry whose ‘ut_type’ value is
  4506. ‘LOGIN_PROCESS’ or ‘USER_PROCESS’, and whose ‘ut_line’ member
  4507. matches the ‘ut_line’ member of the LINE structure. If it finds
  4508. such an entry, it returns a pointer to the entry which is
  4509. statically allocated, and may be overwritten by a subsequent call
  4510. to ‘getutent’, ‘getutid’ or ‘getutline’. You must copy the
  4511. contents of the structure if you wish to save the information.
  4512. A null pointer is returned in case the end of the database is
  4513. reached without a match.
  4514. The ‘getutline’ function may cache the last read entry. Therefore
  4515. if you are using ‘getutline’ to search for multiple occurrences, it
  4516. is necessary to zero out the static data after each call.
  4517. Otherwise ‘getutline’ could just return a pointer to the same entry
  4518. over and over again.
  4519. -- Function: struct utmp * pututline (const struct utmp *UTMP)
  4520. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4521. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4522. The ‘pututline’ function inserts the entry ‘*UTMP’ at the
  4523. appropriate place in the user accounting database. If it finds
  4524. that it is not already at the correct place in the database, it
  4525. uses ‘getutid’ to search for the position to insert the entry,
  4526. however this will not modify the static structure returned by
  4527. ‘getutent’, ‘getutid’ and ‘getutline’. If this search fails, the
  4528. entry is appended to the database.
  4529. The ‘pututline’ function returns a pointer to a copy of the entry
  4530. inserted in the user accounting database, or a null pointer if the
  4531. entry could not be added. The following ‘errno’ error conditions
  4532. are defined for this function:
  4533. ‘EPERM’
  4534. The process does not have the appropriate privileges; you
  4535. cannot modify the user accounting database.
  4536. All the ‘get*’ functions mentioned before store the information they
  4537. return in a static buffer. This can be a problem in multi-threaded
  4538. programs since the data returned for the request is overwritten by the
  4539. return value data in another thread. Therefore the GNU C Library
  4540. provides as extensions three more functions which return the data in a
  4541. user-provided buffer.
  4542. -- Function: int getutent_r (struct utmp *BUFFER, struct utmp **RESULT)
  4543. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4544. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4545. The ‘getutent_r’ is equivalent to the ‘getutent’ function. It
  4546. returns the next entry from the database. But instead of storing
  4547. the information in a static buffer it stores it in the buffer
  4548. pointed to by the parameter BUFFER.
  4549. If the call was successful, the function returns ‘0’ and the
  4550. pointer variable pointed to by the parameter RESULT contains a
  4551. pointer to the buffer which contains the result (this is most
  4552. probably the same value as BUFFER). If something went wrong during
  4553. the execution of ‘getutent_r’ the function returns ‘-1’.
  4554. This function is a GNU extension.
  4555. -- Function: int getutid_r (const struct utmp *ID, struct utmp *BUFFER,
  4556. struct utmp **RESULT)
  4557. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4558. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4559. This function retrieves just like ‘getutid’ the next entry matching
  4560. the information stored in ID. But the result is stored in the
  4561. buffer pointed to by the parameter BUFFER.
  4562. If successful the function returns ‘0’ and the pointer variable
  4563. pointed to by the parameter RESULT contains a pointer to the buffer
  4564. with the result (probably the same as RESULT. If not successful
  4565. the function return ‘-1’.
  4566. This function is a GNU extension.
  4567. -- Function: int getutline_r (const struct utmp *LINE, struct utmp
  4568. *BUFFER, struct utmp **RESULT)
  4569. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4570. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4571. This function retrieves just like ‘getutline’ the next entry
  4572. matching the information stored in LINE. But the result is stored
  4573. in the buffer pointed to by the parameter BUFFER.
  4574. If successful the function returns ‘0’ and the pointer variable
  4575. pointed to by the parameter RESULT contains a pointer to the buffer
  4576. with the result (probably the same as RESULT. If not successful
  4577. the function return ‘-1’.
  4578. This function is a GNU extension.
  4579. In addition to the user accounting database, most systems keep a
  4580. number of similar databases. For example most systems keep a log file
  4581. with all previous logins (usually in ‘/etc/wtmp’ or ‘/var/log/wtmp’).
  4582. For specifying which database to examine, the following function
  4583. should be used.
  4584. -- Function: int utmpname (const char *FILE)
  4585. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock heap |
  4586. AC-Unsafe lock mem | *Note POSIX Safety Concepts::.
  4587. The ‘utmpname’ function changes the name of the database to be
  4588. examined to FILE, and closes any previously opened database. By
  4589. default ‘getutent’, ‘getutid’, ‘getutline’ and ‘pututline’ read
  4590. from and write to the user accounting database.
  4591. The following macros are defined for use as the FILE argument:
  4592. -- Macro: char * _PATH_UTMP
  4593. This macro is used to specify the user accounting database.
  4594. -- Macro: char * _PATH_WTMP
  4595. This macro is used to specify the user accounting log file.
  4596. The ‘utmpname’ function returns a value of ‘0’ if the new name was
  4597. successfully stored, and a value of ‘-1’ to indicate an error.
  4598. Note that ‘utmpname’ does not try to open the database, and that
  4599. therefore the return value does not say anything about whether the
  4600. database can be successfully opened.
  4601. Specially for maintaining log-like databases the GNU C Library
  4602. provides the following function:
  4603. -- Function: void updwtmp (const char *WTMP_FILE, const struct utmp
  4604. *UTMP)
  4605. Preliminary: | MT-Unsafe sig:ALRM timer | AS-Unsafe | AC-Unsafe fd
  4606. | *Note POSIX Safety Concepts::.
  4607. The ‘updwtmp’ function appends the entry *UTMP to the database
  4608. specified by WTMP_FILE. For possible values for the WTMP_FILE
  4609. argument see the ‘utmpname’ function.
  4610. *Portability Note:* Although many operating systems provide a subset
  4611. of these functions, they are not standardized. There are often subtle
  4612. differences in the return types, and there are considerable differences
  4613. between the various definitions of ‘struct utmp’. When programming for
  4614. the GNU C Library, it is probably best to stick with the functions
  4615. described in this section. If however, you want your program to be
  4616. portable, consider using the XPG functions described in *note XPG
  4617. Functions::, or take a look at the BSD compatible functions in *note
  4618. Logging In and Out::.
  4619. 
  4620. File: libc.info, Node: XPG Functions, Next: Logging In and Out, Prev: Manipulating the Database, Up: User Accounting Database
  4621. 30.12.2 XPG User Accounting Database Functions
  4622. ----------------------------------------------
  4623. These functions, described in the X/Open Portability Guide, are declared
  4624. in the header file ‘utmpx.h’.
  4625. -- Data Type: struct utmpx
  4626. The ‘utmpx’ data structure contains at least the following members:
  4627. ‘short int ut_type’
  4628. Specifies the type of login; one of ‘EMPTY’, ‘RUN_LVL’,
  4629. ‘BOOT_TIME’, ‘OLD_TIME’, ‘NEW_TIME’, ‘INIT_PROCESS’,
  4630. ‘LOGIN_PROCESS’, ‘USER_PROCESS’ or ‘DEAD_PROCESS’.
  4631. ‘pid_t ut_pid’
  4632. The process ID number of the login process.
  4633. ‘char ut_line[]’
  4634. The device name of the tty (without ‘/dev/’).
  4635. ‘char ut_id[]’
  4636. The inittab ID of the process.
  4637. ‘char ut_user[]’
  4638. The user’s login name.
  4639. ‘struct timeval ut_tv’
  4640. Time the entry was made. For entries of type ‘OLD_TIME’ this
  4641. is the time when the system clock changed, and for entries of
  4642. type ‘NEW_TIME’ this is the time the system clock was set to.
  4643. In the GNU C Library, ‘struct utmpx’ is identical to ‘struct utmp’
  4644. except for the fact that including ‘utmpx.h’ does not make visible
  4645. the declaration of ‘struct exit_status’.
  4646. The following macros are defined for use as values for the ‘ut_type’
  4647. member of the ‘utmpx’ structure. The values are integer constants and
  4648. are, in the GNU C Library, identical to the definitions in ‘utmp.h’.
  4649. ‘EMPTY’
  4650. This macro is used to indicate that the entry contains no valid
  4651. user accounting information.
  4652. ‘RUN_LVL’
  4653. This macro is used to identify the system’s runlevel.
  4654. ‘BOOT_TIME’
  4655. This macro is used to identify the time of system boot.
  4656. ‘OLD_TIME’
  4657. This macro is used to identify the time when the system clock
  4658. changed.
  4659. ‘NEW_TIME’
  4660. This macro is used to identify the time after the system clock
  4661. changed.
  4662. ‘INIT_PROCESS’
  4663. This macro is used to identify a process spawned by the init
  4664. process.
  4665. ‘LOGIN_PROCESS’
  4666. This macro is used to identify the session leader of a logged in
  4667. user.
  4668. ‘USER_PROCESS’
  4669. This macro is used to identify a user process.
  4670. ‘DEAD_PROCESS’
  4671. This macro is used to identify a terminated process.
  4672. The size of the ‘ut_line’, ‘ut_id’ and ‘ut_user’ arrays can be found
  4673. using the ‘sizeof’ operator.
  4674. -- Function: void setutxent (void)
  4675. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4676. lock fd | *Note POSIX Safety Concepts::.
  4677. This function is similar to ‘setutent’. In the GNU C Library it is
  4678. simply an alias for ‘setutent’.
  4679. -- Function: struct utmpx * getutxent (void)
  4680. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4681. heap lock | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4682. The ‘getutxent’ function is similar to ‘getutent’, but returns a
  4683. pointer to a ‘struct utmpx’ instead of ‘struct utmp’. In the GNU C
  4684. Library it simply is an alias for ‘getutent’.
  4685. -- Function: void endutxent (void)
  4686. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4687. lock | *Note POSIX Safety Concepts::.
  4688. This function is similar to ‘endutent’. In the GNU C Library it is
  4689. simply an alias for ‘endutent’.
  4690. -- Function: struct utmpx * getutxid (const struct utmpx *ID)
  4691. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4692. lock heap | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  4693. This function is similar to ‘getutid’, but uses ‘struct utmpx’
  4694. instead of ‘struct utmp’. In the GNU C Library it is simply an
  4695. alias for ‘getutid’.
  4696. -- Function: struct utmpx * getutxline (const struct utmpx *LINE)
  4697. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4698. heap lock | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4699. This function is similar to ‘getutid’, but uses ‘struct utmpx’
  4700. instead of ‘struct utmp’. In the GNU C Library it is simply an
  4701. alias for ‘getutline’.
  4702. -- Function: struct utmpx * pututxline (const struct utmpx *UTMP)
  4703. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4704. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4705. The ‘pututxline’ function is functionally identical to ‘pututline’,
  4706. but uses ‘struct utmpx’ instead of ‘struct utmp’. In the GNU C
  4707. Library, ‘pututxline’ is simply an alias for ‘pututline’.
  4708. -- Function: int utmpxname (const char *FILE)
  4709. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock heap |
  4710. AC-Unsafe lock mem | *Note POSIX Safety Concepts::.
  4711. The ‘utmpxname’ function is functionally identical to ‘utmpname’.
  4712. In the GNU C Library, ‘utmpxname’ is simply an alias for
  4713. ‘utmpname’.
  4714. You can translate between a traditional ‘struct utmp’ and an XPG
  4715. ‘struct utmpx’ with the following functions. In the GNU C Library,
  4716. these functions are merely copies, since the two structures are
  4717. identical.
  4718. -- Function: int getutmp (const struct utmpx *UTMPX, struct utmp *UTMP)
  4719. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4720. Concepts::.
  4721. ‘getutmp’ copies the information, insofar as the structures are
  4722. compatible, from UTMPX to UTMP.
  4723. -- Function: int getutmpx (const struct utmp *UTMP, struct utmpx
  4724. *UTMPX)
  4725. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4726. Concepts::.
  4727. ‘getutmpx’ copies the information, insofar as the structures are
  4728. compatible, from UTMP to UTMPX.
  4729. 
  4730. File: libc.info, Node: Logging In and Out, Prev: XPG Functions, Up: User Accounting Database
  4731. 30.12.3 Logging In and Out
  4732. --------------------------
  4733. These functions, derived from BSD, are available in the separate
  4734. ‘libutil’ library, and declared in ‘utmp.h’.
  4735. Note that the ‘ut_user’ member of ‘struct utmp’ is called ‘ut_name’
  4736. in BSD. Therefore, ‘ut_name’ is defined as an alias for ‘ut_user’ in
  4737. ‘utmp.h’.
  4738. -- Function: int login_tty (int FILEDES)
  4739. Preliminary: | MT-Unsafe race:ttyname | AS-Unsafe heap lock |
  4740. AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4741. This function makes FILEDES the controlling terminal of the current
  4742. process, redirects standard input, standard output and standard
  4743. error output to this terminal, and closes FILEDES.
  4744. This function returns ‘0’ on successful completion, and ‘-1’ on
  4745. error.
  4746. -- Function: void login (const struct utmp *ENTRY)
  4747. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4748. heap | AC-Unsafe lock corrupt fd mem | *Note POSIX Safety
  4749. Concepts::.
  4750. The ‘login’ functions inserts an entry into the user accounting
  4751. database. The ‘ut_line’ member is set to the name of the terminal
  4752. on standard input. If standard input is not a terminal ‘login’
  4753. uses standard output or standard error output to determine the name
  4754. of the terminal. If ‘struct utmp’ has a ‘ut_type’ member, ‘login’
  4755. sets it to ‘USER_PROCESS’, and if there is an ‘ut_pid’ member, it
  4756. will be set to the process ID of the current process. The
  4757. remaining entries are copied from ENTRY.
  4758. A copy of the entry is written to the user accounting log file.
  4759. -- Function: int logout (const char *UT_LINE)
  4760. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4761. heap | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4762. This function modifies the user accounting database to indicate
  4763. that the user on UT_LINE has logged out.
  4764. The ‘logout’ function returns ‘1’ if the entry was successfully
  4765. written to the database, or ‘0’ on error.
  4766. -- Function: void logwtmp (const char *UT_LINE, const char *UT_NAME,
  4767. const char *UT_HOST)
  4768. Preliminary: | MT-Unsafe sig:ALRM timer | AS-Unsafe | AC-Unsafe fd
  4769. | *Note POSIX Safety Concepts::.
  4770. The ‘logwtmp’ function appends an entry to the user accounting log
  4771. file, for the current time and the information provided in the
  4772. UT_LINE, UT_NAME and UT_HOST arguments.
  4773. *Portability Note:* The BSD ‘struct utmp’ only has the ‘ut_line’,
  4774. ‘ut_name’, ‘ut_host’ and ‘ut_time’ members. Older systems do not even
  4775. have the ‘ut_host’ member.
  4776. 
  4777. File: libc.info, Node: User Database, Next: Group Database, Prev: User Accounting Database, Up: Users and Groups
  4778. 30.13 User Database
  4779. ===================
  4780. This section describes how to search and scan the database of registered
  4781. users. The database itself is kept in the file ‘/etc/passwd’ on most
  4782. systems, but on some systems a special network server gives access to
  4783. it.
  4784. Historically, this database included one-way hashes of user
  4785. passphrases (*note Passphrase Storage::) as well as public information
  4786. about each user (such as their user ID and full name). Many of the
  4787. functions and data structures associated with this database, and the
  4788. filename ‘/etc/passwd’ itself, reflect this history. However, the
  4789. information in this database is available to all users, and it is no
  4790. longer considered safe to make passphrase hashes available to all users,
  4791. so they have been moved to a “shadow” database that can only be accessed
  4792. with special privileges.
  4793. * Menu:
  4794. * User Data Structure:: What each user record contains.
  4795. * Lookup User:: How to look for a particular user.
  4796. * Scanning All Users:: Scanning the list of all users, one by one.
  4797. * Writing a User Entry:: How a program can rewrite a user’s record.
  4798. 
  4799. File: libc.info, Node: User Data Structure, Next: Lookup User, Up: User Database
  4800. 30.13.1 The Data Structure that Describes a User
  4801. ------------------------------------------------
  4802. The functions and data structures for accessing the system user database
  4803. are declared in the header file ‘pwd.h’.
  4804. -- Data Type: struct passwd
  4805. The ‘passwd’ data structure is used to hold information about
  4806. entries in the system user data base. It has at least the
  4807. following members:
  4808. ‘char *pw_name’
  4809. The user’s login name.
  4810. ‘char *pw_passwd’
  4811. Historically, this field would hold the one-way hash of the
  4812. user’s passphrase. Nowadays, it will almost always be the
  4813. single character ‘x’, indicating that the hash is in the
  4814. shadow database.
  4815. ‘uid_t pw_uid’
  4816. The user ID number.
  4817. ‘gid_t pw_gid’
  4818. The user’s default group ID number.
  4819. ‘char *pw_gecos’
  4820. A string typically containing the user’s real name, and
  4821. possibly other information such as a phone number.
  4822. ‘char *pw_dir’
  4823. The user’s home directory, or initial working directory. This
  4824. might be a null pointer, in which case the interpretation is
  4825. system-dependent.
  4826. ‘char *pw_shell’
  4827. The user’s default shell, or the initial program run when the
  4828. user logs in. This might be a null pointer, indicating that
  4829. the system default should be used.
  4830. 
  4831. File: libc.info, Node: Lookup User, Next: Scanning All Users, Prev: User Data Structure, Up: User Database
  4832. 30.13.2 Looking Up One User
  4833. ---------------------------
  4834. You can search the system user database for information about a specific
  4835. user using ‘getpwuid’ or ‘getpwnam’. These functions are declared in
  4836. ‘pwd.h’.
  4837. -- Function: struct passwd * getpwuid (uid_t UID)
  4838. Preliminary: | MT-Unsafe race:pwuid locale | AS-Unsafe dlopen
  4839. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4840. Safety Concepts::.
  4841. This function returns a pointer to a statically-allocated structure
  4842. containing information about the user whose user ID is UID. This
  4843. structure may be overwritten on subsequent calls to ‘getpwuid’.
  4844. A null pointer value indicates there is no user in the data base
  4845. with user ID UID.
  4846. -- Function: int getpwuid_r (uid_t UID, struct passwd *RESULT_BUF, char
  4847. *BUFFER, size_t BUFLEN, struct passwd **RESULT)
  4848. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4849. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4850. This function is similar to ‘getpwuid’ in that it returns
  4851. information about the user whose user ID is UID. However, it fills
  4852. the user supplied structure pointed to by RESULT_BUF with the
  4853. information instead of using a static buffer. The first BUFLEN
  4854. bytes of the additional buffer pointed to by BUFFER are used to
  4855. contain additional information, normally strings which are pointed
  4856. to by the elements of the result structure.
  4857. If a user with ID UID is found, the pointer returned in RESULT
  4858. points to the record which contains the wanted data (i.e., RESULT
  4859. contains the value RESULT_BUF). If no user is found or if an error
  4860. occurred, the pointer returned in RESULT is a null pointer. The
  4861. function returns zero or an error code. If the buffer BUFFER is
  4862. too small to contain all the needed information, the error code
  4863. ‘ERANGE’ is returned and ‘errno’ is set to ‘ERANGE’.
  4864. -- Function: struct passwd * getpwnam (const char *NAME)
  4865. Preliminary: | MT-Unsafe race:pwnam locale | AS-Unsafe dlopen
  4866. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4867. Safety Concepts::.
  4868. This function returns a pointer to a statically-allocated structure
  4869. containing information about the user whose user name is NAME.
  4870. This structure may be overwritten on subsequent calls to
  4871. ‘getpwnam’.
  4872. A null pointer return indicates there is no user named NAME.
  4873. -- Function: int getpwnam_r (const char *NAME, struct passwd
  4874. *RESULT_BUF, char *BUFFER, size_t BUFLEN, struct passwd
  4875. **RESULT)
  4876. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4877. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4878. This function is similar to ‘getpwnam’ in that it returns
  4879. information about the user whose user name is NAME. However, like
  4880. ‘getpwuid_r’, it fills the user supplied buffers in RESULT_BUF and
  4881. BUFFER with the information instead of using a static buffer.
  4882. The return values are the same as for ‘getpwuid_r’.
  4883. 
  4884. File: libc.info, Node: Scanning All Users, Next: Writing a User Entry, Prev: Lookup User, Up: User Database
  4885. 30.13.3 Scanning the List of All Users
  4886. --------------------------------------
  4887. This section explains how a program can read the list of all users in
  4888. the system, one user at a time. The functions described here are
  4889. declared in ‘pwd.h’.
  4890. You can use the ‘fgetpwent’ function to read user entries from a
  4891. particular file.
  4892. -- Function: struct passwd * fgetpwent (FILE *STREAM)
  4893. Preliminary: | MT-Unsafe race:fpwent | AS-Unsafe corrupt lock |
  4894. AC-Unsafe corrupt lock | *Note POSIX Safety Concepts::.
  4895. This function reads the next user entry from STREAM and returns a
  4896. pointer to the entry. The structure is statically allocated and is
  4897. rewritten on subsequent calls to ‘fgetpwent’. You must copy the
  4898. contents of the structure if you wish to save the information.
  4899. The stream must correspond to a file in the same format as the
  4900. standard user database file.
  4901. -- Function: int fgetpwent_r (FILE *STREAM, struct passwd *RESULT_BUF,
  4902. char *BUFFER, size_t BUFLEN, struct passwd **RESULT)
  4903. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  4904. | *Note POSIX Safety Concepts::.
  4905. This function is similar to ‘fgetpwent’ in that it reads the next
  4906. user entry from STREAM. But the result is returned in the
  4907. structure pointed to by RESULT_BUF. The first BUFLEN bytes of the
  4908. additional buffer pointed to by BUFFER are used to contain
  4909. additional information, normally strings which are pointed to by
  4910. the elements of the result structure.
  4911. The stream must correspond to a file in the same format as the
  4912. standard user database file.
  4913. If the function returns zero RESULT points to the structure with
  4914. the wanted data (normally this is in RESULT_BUF). If errors
  4915. occurred the return value is nonzero and RESULT contains a null
  4916. pointer.
  4917. The way to scan all the entries in the user database is with
  4918. ‘setpwent’, ‘getpwent’, and ‘endpwent’.
  4919. -- Function: void setpwent (void)
  4920. Preliminary: | MT-Unsafe race:pwent locale | AS-Unsafe dlopen
  4921. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4922. Safety Concepts::.
  4923. This function initializes a stream which ‘getpwent’ and
  4924. ‘getpwent_r’ use to read the user database.
  4925. -- Function: struct passwd * getpwent (void)
  4926. Preliminary: | MT-Unsafe race:pwent race:pwentbuf locale |
  4927. AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem |
  4928. *Note POSIX Safety Concepts::.
  4929. The ‘getpwent’ function reads the next entry from the stream
  4930. initialized by ‘setpwent’. It returns a pointer to the entry. The
  4931. structure is statically allocated and is rewritten on subsequent
  4932. calls to ‘getpwent’. You must copy the contents of the structure
  4933. if you wish to save the information.
  4934. A null pointer is returned when no more entries are available.
  4935. -- Function: int getpwent_r (struct passwd *RESULT_BUF, char *BUFFER,
  4936. size_t BUFLEN, struct passwd **RESULT)
  4937. Preliminary: | MT-Unsafe race:pwent locale | AS-Unsafe dlopen
  4938. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4939. Safety Concepts::.
  4940. This function is similar to ‘getpwent’ in that it returns the next
  4941. entry from the stream initialized by ‘setpwent’. Like
  4942. ‘fgetpwent_r’, it uses the user-supplied buffers in RESULT_BUF and
  4943. BUFFER to return the information requested.
  4944. The return values are the same as for ‘fgetpwent_r’.
  4945. -- Function: void endpwent (void)
  4946. Preliminary: | MT-Unsafe race:pwent locale | AS-Unsafe dlopen
  4947. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4948. Safety Concepts::.
  4949. This function closes the internal stream used by ‘getpwent’ or
  4950. ‘getpwent_r’.
  4951. 
  4952. File: libc.info, Node: Writing a User Entry, Prev: Scanning All Users, Up: User Database
  4953. 30.13.4 Writing a User Entry
  4954. ----------------------------
  4955. -- Function: int putpwent (const struct passwd *P, FILE *STREAM)
  4956. Preliminary: | MT-Safe locale | AS-Unsafe corrupt | AC-Unsafe lock
  4957. corrupt | *Note POSIX Safety Concepts::.
  4958. This function writes the user entry ‘*P’ to the stream STREAM, in
  4959. the format used for the standard user database file. The return
  4960. value is zero on success and nonzero on failure.
  4961. This function exists for compatibility with SVID. We recommend that
  4962. you avoid using it, because it makes sense only on the assumption
  4963. that the ‘struct passwd’ structure has no members except the
  4964. standard ones; on a system which merges the traditional Unix data
  4965. base with other extended information about users, adding an entry
  4966. using this function would inevitably leave out much of the
  4967. important information.
  4968. The group and user ID fields are left empty if the group or user
  4969. name starts with a - or +.
  4970. The function ‘putpwent’ is declared in ‘pwd.h’.
  4971. 
  4972. File: libc.info, Node: Group Database, Next: Database Example, Prev: User Database, Up: Users and Groups
  4973. 30.14 Group Database
  4974. ====================
  4975. This section describes how to search and scan the database of registered
  4976. groups. The database itself is kept in the file ‘/etc/group’ on most
  4977. systems, but on some systems a special network service provides access
  4978. to it.
  4979. * Menu:
  4980. * Group Data Structure:: What each group record contains.
  4981. * Lookup Group:: How to look for a particular group.
  4982. * Scanning All Groups:: Scanning the list of all groups.
  4983. 
  4984. File: libc.info, Node: Group Data Structure, Next: Lookup Group, Up: Group Database
  4985. 30.14.1 The Data Structure for a Group
  4986. --------------------------------------
  4987. The functions and data structures for accessing the system group
  4988. database are declared in the header file ‘grp.h’.
  4989. -- Data Type: struct group
  4990. The ‘group’ structure is used to hold information about an entry in
  4991. the system group database. It has at least the following members:
  4992. ‘char *gr_name’
  4993. The name of the group.
  4994. ‘gid_t gr_gid’
  4995. The group ID of the group.
  4996. ‘char **gr_mem’
  4997. A vector of pointers to the names of users in the group. Each
  4998. user name is a null-terminated string, and the vector itself
  4999. is terminated by a null pointer.
  5000. 
  5001. File: libc.info, Node: Lookup Group, Next: Scanning All Groups, Prev: Group Data Structure, Up: Group Database
  5002. 30.14.2 Looking Up One Group
  5003. ----------------------------
  5004. You can search the group database for information about a specific group
  5005. using ‘getgrgid’ or ‘getgrnam’. These functions are declared in
  5006. ‘grp.h’.
  5007. -- Function: struct group * getgrgid (gid_t GID)
  5008. Preliminary: | MT-Unsafe race:grgid locale | AS-Unsafe dlopen
  5009. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5010. Safety Concepts::.
  5011. This function returns a pointer to a statically-allocated structure
  5012. containing information about the group whose group ID is GID. This
  5013. structure may be overwritten by subsequent calls to ‘getgrgid’.
  5014. A null pointer indicates there is no group with ID GID.
  5015. -- Function: int getgrgid_r (gid_t GID, struct group *RESULT_BUF, char
  5016. *BUFFER, size_t BUFLEN, struct group **RESULT)
  5017. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  5018. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  5019. This function is similar to ‘getgrgid’ in that it returns
  5020. information about the group whose group ID is GID. However, it
  5021. fills the user supplied structure pointed to by RESULT_BUF with the
  5022. information instead of using a static buffer. The first BUFLEN
  5023. bytes of the additional buffer pointed to by BUFFER are used to
  5024. contain additional information, normally strings which are pointed
  5025. to by the elements of the result structure.
  5026. If a group with ID GID is found, the pointer returned in RESULT
  5027. points to the record which contains the wanted data (i.e., RESULT
  5028. contains the value RESULT_BUF). If no group is found or if an
  5029. error occurred, the pointer returned in RESULT is a null pointer.
  5030. The function returns zero or an error code. If the buffer BUFFER
  5031. is too small to contain all the needed information, the error code
  5032. ‘ERANGE’ is returned and ‘errno’ is set to ‘ERANGE’.
  5033. -- Function: struct group * getgrnam (const char *NAME)
  5034. Preliminary: | MT-Unsafe race:grnam locale | AS-Unsafe dlopen
  5035. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5036. Safety Concepts::.
  5037. This function returns a pointer to a statically-allocated structure
  5038. containing information about the group whose group name is NAME.
  5039. This structure may be overwritten by subsequent calls to
  5040. ‘getgrnam’.
  5041. A null pointer indicates there is no group named NAME.
  5042. -- Function: int getgrnam_r (const char *NAME, struct group
  5043. *RESULT_BUF, char *BUFFER, size_t BUFLEN, struct group
  5044. **RESULT)
  5045. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  5046. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  5047. This function is similar to ‘getgrnam’ in that it returns
  5048. information about the group whose group name is NAME. Like
  5049. ‘getgrgid_r’, it uses the user supplied buffers in RESULT_BUF and
  5050. BUFFER, not a static buffer.
  5051. The return values are the same as for ‘getgrgid_r’.
  5052. 
  5053. File: libc.info, Node: Scanning All Groups, Prev: Lookup Group, Up: Group Database
  5054. 30.14.3 Scanning the List of All Groups
  5055. ---------------------------------------
  5056. This section explains how a program can read the list of all groups in
  5057. the system, one group at a time. The functions described here are
  5058. declared in ‘grp.h’.
  5059. You can use the ‘fgetgrent’ function to read group entries from a
  5060. particular file.
  5061. -- Function: struct group * fgetgrent (FILE *STREAM)
  5062. Preliminary: | MT-Unsafe race:fgrent | AS-Unsafe corrupt lock |
  5063. AC-Unsafe corrupt lock | *Note POSIX Safety Concepts::.
  5064. The ‘fgetgrent’ function reads the next entry from STREAM. It
  5065. returns a pointer to the entry. The structure is statically
  5066. allocated and is overwritten on subsequent calls to ‘fgetgrent’.
  5067. You must copy the contents of the structure if you wish to save the
  5068. information.
  5069. The stream must correspond to a file in the same format as the
  5070. standard group database file.
  5071. -- Function: int fgetgrent_r (FILE *STREAM, struct group *RESULT_BUF,
  5072. char *BUFFER, size_t BUFLEN, struct group **RESULT)
  5073. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  5074. | *Note POSIX Safety Concepts::.
  5075. This function is similar to ‘fgetgrent’ in that it reads the next
  5076. user entry from STREAM. But the result is returned in the
  5077. structure pointed to by RESULT_BUF. The first BUFLEN bytes of the
  5078. additional buffer pointed to by BUFFER are used to contain
  5079. additional information, normally strings which are pointed to by
  5080. the elements of the result structure.
  5081. This stream must correspond to a file in the same format as the
  5082. standard group database file.
  5083. If the function returns zero RESULT points to the structure with
  5084. the wanted data (normally this is in RESULT_BUF). If errors
  5085. occurred the return value is non-zero and RESULT contains a null
  5086. pointer.
  5087. The way to scan all the entries in the group database is with
  5088. ‘setgrent’, ‘getgrent’, and ‘endgrent’.
  5089. -- Function: void setgrent (void)
  5090. Preliminary: | MT-Unsafe race:grent locale | AS-Unsafe dlopen
  5091. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5092. Safety Concepts::.
  5093. This function initializes a stream for reading from the group data
  5094. base. You use this stream by calling ‘getgrent’ or ‘getgrent_r’.
  5095. -- Function: struct group * getgrent (void)
  5096. Preliminary: | MT-Unsafe race:grent race:grentbuf locale |
  5097. AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem |
  5098. *Note POSIX Safety Concepts::.
  5099. The ‘getgrent’ function reads the next entry from the stream
  5100. initialized by ‘setgrent’. It returns a pointer to the entry. The
  5101. structure is statically allocated and is overwritten on subsequent
  5102. calls to ‘getgrent’. You must copy the contents of the structure
  5103. if you wish to save the information.
  5104. -- Function: int getgrent_r (struct group *RESULT_BUF, char *BUFFER,
  5105. size_t BUFLEN, struct group **RESULT)
  5106. Preliminary: | MT-Unsafe race:grent locale | AS-Unsafe dlopen
  5107. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5108. Safety Concepts::.
  5109. This function is similar to ‘getgrent’ in that it returns the next
  5110. entry from the stream initialized by ‘setgrent’. Like
  5111. ‘fgetgrent_r’, it places the result in user-supplied buffers
  5112. pointed to by RESULT_BUF and BUFFER.
  5113. If the function returns zero RESULT contains a pointer to the data
  5114. (normally equal to RESULT_BUF). If errors occurred the return
  5115. value is non-zero and RESULT contains a null pointer.
  5116. -- Function: void endgrent (void)
  5117. Preliminary: | MT-Unsafe race:grent locale | AS-Unsafe dlopen
  5118. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5119. Safety Concepts::.
  5120. This function closes the internal stream used by ‘getgrent’ or
  5121. ‘getgrent_r’.
  5122. 
  5123. File: libc.info, Node: Database Example, Next: Netgroup Database, Prev: Group Database, Up: Users and Groups
  5124. 30.15 User and Group Database Example
  5125. =====================================
  5126. Here is an example program showing the use of the system database
  5127. inquiry functions. The program prints some information about the user
  5128. running the program.
  5129. #include <grp.h>
  5130. #include <pwd.h>
  5131. #include <sys/types.h>
  5132. #include <unistd.h>
  5133. #include <stdlib.h>
  5134. int
  5135. main (void)
  5136. {
  5137. uid_t me;
  5138. struct passwd *my_passwd;
  5139. struct group *my_group;
  5140. char **members;
  5141. /* Get information about the user ID. */
  5142. me = getuid ();
  5143. my_passwd = getpwuid (me);
  5144. if (!my_passwd)
  5145. {
  5146. printf ("Couldn't find out about user %d.\n", (int) me);
  5147. exit (EXIT_FAILURE);
  5148. }
  5149. /* Print the information. */
  5150. printf ("I am %s.\n", my_passwd->pw_gecos);
  5151. printf ("My login name is %s.\n", my_passwd->pw_name);
  5152. printf ("My uid is %d.\n", (int) (my_passwd->pw_uid));
  5153. printf ("My home directory is %s.\n", my_passwd->pw_dir);
  5154. printf ("My default shell is %s.\n", my_passwd->pw_shell);
  5155. /* Get information about the default group ID. */
  5156. my_group = getgrgid (my_passwd->pw_gid);
  5157. if (!my_group)
  5158. {
  5159. printf ("Couldn't find out about group %d.\n",
  5160. (int) my_passwd->pw_gid);
  5161. exit (EXIT_FAILURE);
  5162. }
  5163. /* Print the information. */
  5164. printf ("My default group is %s (%d).\n",
  5165. my_group->gr_name, (int) (my_passwd->pw_gid));
  5166. printf ("The members of this group are:\n");
  5167. members = my_group->gr_mem;
  5168. while (*members)
  5169. {
  5170. printf (" %s\n", *(members));
  5171. members++;
  5172. }
  5173. return EXIT_SUCCESS;
  5174. }
  5175. Here is some output from this program:
  5176. I am Throckmorton Snurd.
  5177. My login name is snurd.
  5178. My uid is 31093.
  5179. My home directory is /home/fsg/snurd.
  5180. My default shell is /bin/sh.
  5181. My default group is guest (12).
  5182. The members of this group are:
  5183. friedman
  5184. tami
  5185. 
  5186. File: libc.info, Node: Netgroup Database, Prev: Database Example, Up: Users and Groups
  5187. 30.16 Netgroup Database
  5188. =======================
  5189. * Menu:
  5190. * Netgroup Data:: Data in the Netgroup database and where
  5191. it comes from.
  5192. * Lookup Netgroup:: How to look for a particular netgroup.
  5193. * Netgroup Membership:: How to test for netgroup membership.
  5194. 
  5195. File: libc.info, Node: Netgroup Data, Next: Lookup Netgroup, Up: Netgroup Database
  5196. 30.16.1 Netgroup Data
  5197. ---------------------
  5198. Sometimes it is useful to group users according to other criteria (*note
  5199. Group Database::). E.g., it is useful to associate a certain group of
  5200. users with a certain machine. On the other hand grouping of host names
  5201. is not supported so far.
  5202. In Sun Microsystems’ SunOS appeared a new kind of database, the
  5203. netgroup database. It allows grouping hosts, users, and domains freely,
  5204. giving them individual names. To be more concrete, a netgroup is a list
  5205. of triples consisting of a host name, a user name, and a domain name
  5206. where any of the entries can be a wildcard entry matching all inputs. A
  5207. last possibility is that names of other netgroups can also be given in
  5208. the list specifying a netgroup. So one can construct arbitrary
  5209. hierarchies without loops.
  5210. Sun’s implementation allows netgroups only for the ‘nis’ or ‘nisplus’
  5211. service, *note Services in the NSS configuration::. The implementation
  5212. in the GNU C Library has no such restriction. An entry in either of the
  5213. input services must have the following form:
  5214. GROUPNAME ( GROUPNAME | (HOSTNAME,USERNAME,domainname) )+
  5215. Any of the fields in the triple can be empty which means anything
  5216. matches. While describing the functions we will see that the opposite
  5217. case is useful as well. I.e., there may be entries which will not match
  5218. any input. For entries like this, a name consisting of the single
  5219. character ‘-’ shall be used.
  5220. 
  5221. File: libc.info, Node: Lookup Netgroup, Next: Netgroup Membership, Prev: Netgroup Data, Up: Netgroup Database
  5222. 30.16.2 Looking up one Netgroup
  5223. -------------------------------
  5224. The lookup functions for netgroups are a bit different than all other
  5225. system database handling functions. Since a single netgroup can contain
  5226. many entries a two-step process is needed. First a single netgroup is
  5227. selected and then one can iterate over all entries in this netgroup.
  5228. These functions are declared in ‘netdb.h’.
  5229. -- Function: int setnetgrent (const char *NETGROUP)
  5230. Preliminary: | MT-Unsafe race:netgrent locale | AS-Unsafe dlopen
  5231. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5232. Safety Concepts::.
  5233. A call to this function initializes the internal state of the
  5234. library to allow following calls of ‘getnetgrent’ to iterate over
  5235. all entries in the netgroup with name NETGROUP.
  5236. When the call is successful (i.e., when a netgroup with this name
  5237. exists) the return value is ‘1’. When the return value is ‘0’ no
  5238. netgroup of this name is known or some other error occurred.
  5239. It is important to remember that there is only one single state for
  5240. iterating the netgroups. Even if the programmer uses the
  5241. ‘getnetgrent_r’ function the result is not really reentrant since always
  5242. only one single netgroup at a time can be processed. If the program
  5243. needs to process more than one netgroup simultaneously she must protect
  5244. this by using external locking. This problem was introduced in the
  5245. original netgroups implementation in SunOS and since we must stay
  5246. compatible it is not possible to change this.
  5247. Some other functions also use the netgroups state. Currently these
  5248. are the ‘innetgr’ function and parts of the implementation of the
  5249. ‘compat’ service part of the NSS implementation.
  5250. -- Function: int getnetgrent (char **HOSTP, char **USERP, char
  5251. **DOMAINP)
  5252. Preliminary: | MT-Unsafe race:netgrent race:netgrentbuf locale |
  5253. AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem |
  5254. *Note POSIX Safety Concepts::.
  5255. This function returns the next unprocessed entry of the currently
  5256. selected netgroup. The string pointers, in which addresses are
  5257. passed in the arguments HOSTP, USERP, and DOMAINP, will contain
  5258. after a successful call pointers to appropriate strings. If the
  5259. string in the next entry is empty the pointer has the value ‘NULL’.
  5260. The returned string pointers are only valid if none of the netgroup
  5261. related functions are called.
  5262. The return value is ‘1’ if the next entry was successfully read. A
  5263. value of ‘0’ means no further entries exist or internal errors
  5264. occurred.
  5265. -- Function: int getnetgrent_r (char **HOSTP, char **USERP, char
  5266. **DOMAINP, char *BUFFER, size_t BUFLEN)
  5267. Preliminary: | MT-Unsafe race:netgrent locale | AS-Unsafe dlopen
  5268. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5269. Safety Concepts::.
  5270. This function is similar to ‘getnetgrent’ with only one exception:
  5271. the strings the three string pointers HOSTP, USERP, and DOMAINP
  5272. point to, are placed in the buffer of BUFLEN bytes starting at
  5273. BUFFER. This means the returned values are valid even after other
  5274. netgroup related functions are called.
  5275. The return value is ‘1’ if the next entry was successfully read and
  5276. the buffer contains enough room to place the strings in it. ‘0’ is
  5277. returned in case no more entries are found, the buffer is too
  5278. small, or internal errors occurred.
  5279. This function is a GNU extension. The original implementation in
  5280. the SunOS libc does not provide this function.
  5281. -- Function: void endnetgrent (void)
  5282. Preliminary: | MT-Unsafe race:netgrent | AS-Unsafe dlopen plugin
  5283. heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX Safety
  5284. Concepts::.
  5285. This function frees all buffers which were allocated to process the
  5286. last selected netgroup. As a result all string pointers returned
  5287. by calls to ‘getnetgrent’ are invalid afterwards.
  5288. 
  5289. File: libc.info, Node: Netgroup Membership, Prev: Lookup Netgroup, Up: Netgroup Database
  5290. 30.16.3 Testing for Netgroup Membership
  5291. ---------------------------------------
  5292. It is often not necessary to scan the whole netgroup since often the
  5293. only interesting question is whether a given entry is part of the
  5294. selected netgroup.
  5295. -- Function: int innetgr (const char *NETGROUP, const char *HOST, const
  5296. char *USER, const char *DOMAIN)
  5297. Preliminary: | MT-Unsafe race:netgrent locale | AS-Unsafe dlopen
  5298. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  5299. Safety Concepts::.
  5300. This function tests whether the triple specified by the parameters
  5301. HOST, USER, and DOMAIN is part of the netgroup NETGROUP. Using
  5302. this function has the advantage that
  5303. 1. no other netgroup function can use the global netgroup state
  5304. since internal locking is used and
  5305. 2. the function is implemented more efficiently than successive
  5306. calls to the other ‘set’/‘get’/‘endnetgrent’ functions.
  5307. Any of the pointers HOST, USER, or DOMAIN can be ‘NULL’ which means
  5308. any value is accepted in this position. This is also true for the
  5309. name ‘-’ which should not match any other string otherwise.
  5310. The return value is ‘1’ if an entry matching the given triple is
  5311. found in the netgroup. The return value is ‘0’ if the netgroup
  5312. itself is not found, the netgroup does not contain the triple or
  5313. internal errors occurred.
  5314. 
  5315. File: libc.info, Node: System Management, Next: System Configuration, Prev: Users and Groups, Up: Top
  5316. 31 System Management
  5317. ********************
  5318. This chapter describes facilities for controlling the system that
  5319. underlies a process (including the operating system and hardware) and
  5320. for getting information about it. Anyone can generally use the
  5321. informational facilities, but usually only a properly privileged process
  5322. can make changes.
  5323. * Menu:
  5324. * Host Identification:: Determining the name of the machine.
  5325. * Platform Type:: Determining operating system and basic
  5326. machine type
  5327. * Filesystem Handling:: Controlling/querying mounts
  5328. To get information on parameters of the system that are built into
  5329. the system, such as the maximum length of a filename, *note System
  5330. Configuration::.
  5331. 
  5332. File: libc.info, Node: Host Identification, Next: Platform Type, Up: System Management
  5333. 31.1 Host Identification
  5334. ========================
  5335. This section explains how to identify the particular system on which
  5336. your program is running. First, let’s review the various ways computer
  5337. systems are named, which is a little complicated because of the history
  5338. of the development of the Internet.
  5339. Every Unix system (also known as a host) has a host name, whether
  5340. it’s connected to a network or not. In its simplest form, as used
  5341. before computer networks were an issue, it’s just a word like ‘chicken’.
  5342. But any system attached to the Internet or any network like it
  5343. conforms to a more rigorous naming convention as part of the Domain Name
  5344. System (DNS). In the DNS, every host name is composed of two parts:
  5345. 1. hostname
  5346. 2. domain name
  5347. You will note that “hostname” looks a lot like “host name”, but is
  5348. not the same thing, and that people often incorrectly refer to entire
  5349. host names as “domain names.”
  5350. In the DNS, the full host name is properly called the FQDN (Fully
  5351. Qualified Domain Name) and consists of the hostname, then a period, then
  5352. the domain name. The domain name itself usually has multiple components
  5353. separated by periods. So for example, a system’s hostname may be
  5354. ‘chicken’ and its domain name might be ‘ai.mit.edu’, so its FQDN (which
  5355. is its host name) is ‘chicken.ai.mit.edu’.
  5356. Adding to the confusion, though, is that the DNS is not the only name
  5357. space in which a computer needs to be known. Another name space is the
  5358. NIS (aka YP) name space. For NIS purposes, there is another domain
  5359. name, which is called the NIS domain name or the YP domain name. It
  5360. need not have anything to do with the DNS domain name.
  5361. Confusing things even more is the fact that in the DNS, it is
  5362. possible for multiple FQDNs to refer to the same system. However, there
  5363. is always exactly one of them that is the true host name, and it is
  5364. called the canonical FQDN.
  5365. In some contexts, the host name is called a “node name.”
  5366. For more information on DNS host naming, see *note Host Names::.
  5367. Prototypes for these functions appear in ‘unistd.h’.
  5368. The programs ‘hostname’, ‘hostid’, and ‘domainname’ work by calling
  5369. these functions.
  5370. -- Function: int gethostname (char *NAME, size_t SIZE)
  5371. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5372. Concepts::.
  5373. This function returns the host name of the system on which it is
  5374. called, in the array NAME. The SIZE argument specifies the size of
  5375. this array, in bytes. Note that this is _not_ the DNS hostname.
  5376. If the system participates in the DNS, this is the FQDN (see
  5377. above).
  5378. The return value is ‘0’ on success and ‘-1’ on failure. In the GNU
  5379. C Library, ‘gethostname’ fails if SIZE is not large enough; then
  5380. you can try again with a larger array. The following ‘errno’ error
  5381. condition is defined for this function:
  5382. ‘ENAMETOOLONG’
  5383. The SIZE argument is less than the size of the host name plus
  5384. one.
  5385. On some systems, there is a symbol for the maximum possible host
  5386. name length: ‘MAXHOSTNAMELEN’. It is defined in ‘sys/param.h’.
  5387. But you can’t count on this to exist, so it is cleaner to handle
  5388. failure and try again.
  5389. ‘gethostname’ stores the beginning of the host name in NAME even if
  5390. the host name won’t entirely fit. For some purposes, a truncated
  5391. host name is good enough. If it is, you can ignore the error code.
  5392. -- Function: int sethostname (const char *NAME, size_t LENGTH)
  5393. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5394. Concepts::.
  5395. The ‘sethostname’ function sets the host name of the system that
  5396. calls it to NAME, a string with length LENGTH. Only privileged
  5397. processes are permitted to do this.
  5398. Usually ‘sethostname’ gets called just once, at system boot time.
  5399. Often, the program that calls it sets it to the value it finds in
  5400. the file ‘/etc/hostname’.
  5401. Be sure to set the host name to the full host name, not just the
  5402. DNS hostname (see above).
  5403. The return value is ‘0’ on success and ‘-1’ on failure. The
  5404. following ‘errno’ error condition is defined for this function:
  5405. ‘EPERM’
  5406. This process cannot set the host name because it is not
  5407. privileged.
  5408. -- Function: int getdomainnname (char *NAME, size_t LENGTH)
  5409. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5410. Concepts::.
  5411. ‘getdomainname’ returns the NIS (aka YP) domain name of the system
  5412. on which it is called. Note that this is not the more popular DNS
  5413. domain name. Get that with ‘gethostname’.
  5414. The specifics of this function are analogous to ‘gethostname’,
  5415. above.
  5416. -- Function: int setdomainname (const char *NAME, size_t LENGTH)
  5417. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5418. Concepts::.
  5419. ‘setdomainname’ sets the NIS (aka YP) domain name of the system on
  5420. which it is called. Note that this is not the more popular DNS
  5421. domain name. Set that with ‘sethostname’.
  5422. The specifics of this function are analogous to ‘sethostname’,
  5423. above.
  5424. -- Function: long int gethostid (void)
  5425. Preliminary: | MT-Safe hostid env locale | AS-Unsafe dlopen plugin
  5426. corrupt heap lock | AC-Unsafe lock corrupt mem fd | *Note POSIX
  5427. Safety Concepts::.
  5428. This function returns the “host ID” of the machine the program is
  5429. running on. By convention, this is usually the primary Internet IP
  5430. address of that machine, converted to a ‘long int’. However, on
  5431. some systems it is a meaningless but unique number which is
  5432. hard-coded for each machine.
  5433. This is not widely used. It arose in BSD 4.2, but was dropped in
  5434. BSD 4.4. It is not required by POSIX.
  5435. The proper way to query the IP address is to use ‘gethostbyname’ on
  5436. the results of ‘gethostname’. For more information on IP
  5437. addresses, *Note Host Addresses::.
  5438. -- Function: int sethostid (long int ID)
  5439. Preliminary: | MT-Unsafe const:hostid | AS-Unsafe | AC-Unsafe
  5440. corrupt fd | *Note POSIX Safety Concepts::.
  5441. The ‘sethostid’ function sets the “host ID” of the host machine to
  5442. ID. Only privileged processes are permitted to do this. Usually
  5443. it happens just once, at system boot time.
  5444. The proper way to establish the primary IP address of a system is
  5445. to configure the IP address resolver to associate that IP address
  5446. with the system’s host name as returned by ‘gethostname’. For
  5447. example, put a record for the system in ‘/etc/hosts’.
  5448. See ‘gethostid’ above for more information on host ids.
  5449. The return value is ‘0’ on success and ‘-1’ on failure. The
  5450. following ‘errno’ error conditions are defined for this function:
  5451. ‘EPERM’
  5452. This process cannot set the host name because it is not
  5453. privileged.
  5454. ‘ENOSYS’
  5455. The operating system does not support setting the host ID. On
  5456. some systems, the host ID is a meaningless but unique number
  5457. hard-coded for each machine.
  5458. 
  5459. File: libc.info, Node: Platform Type, Next: Filesystem Handling, Prev: Host Identification, Up: System Management
  5460. 31.2 Platform Type Identification
  5461. =================================
  5462. You can use the ‘uname’ function to find out some information about the
  5463. type of computer your program is running on. This function and the
  5464. associated data type are declared in the header file ‘sys/utsname.h’.
  5465. As a bonus, ‘uname’ also gives some information identifying the
  5466. particular system your program is running on. This is the same
  5467. information which you can get with functions targeted to this purpose
  5468. described in *note Host Identification::.
  5469. -- Data Type: struct utsname
  5470. The ‘utsname’ structure is used to hold information returned by the
  5471. ‘uname’ function. It has the following members:
  5472. ‘char sysname[]’
  5473. This is the name of the operating system in use.
  5474. ‘char release[]’
  5475. This is the current release level of the operating system
  5476. implementation.
  5477. ‘char version[]’
  5478. This is the current version level within the release of the
  5479. operating system.
  5480. ‘char machine[]’
  5481. This is a description of the type of hardware that is in use.
  5482. Some systems provide a mechanism to interrogate the kernel
  5483. directly for this information. On systems without such a
  5484. mechanism, the GNU C Library fills in this field based on the
  5485. configuration name that was specified when building and
  5486. installing the library.
  5487. GNU uses a three-part name to describe a system configuration;
  5488. the three parts are CPU, MANUFACTURER and SYSTEM-TYPE, and
  5489. they are separated with dashes. Any possible combination of
  5490. three names is potentially meaningful, but most such
  5491. combinations are meaningless in practice and even the
  5492. meaningful ones are not necessarily supported by any
  5493. particular GNU program.
  5494. Since the value in ‘machine’ is supposed to describe just the
  5495. hardware, it consists of the first two parts of the
  5496. configuration name: ‘CPU-MANUFACTURER’. For example, it might
  5497. be one of these:
  5498. ‘"sparc-sun"’, ‘"i386-ANYTHING"’, ‘"m68k-hp"’,
  5499. ‘"m68k-sony"’, ‘"m68k-sun"’, ‘"mips-dec"’
  5500. ‘char nodename[]’
  5501. This is the host name of this particular computer. In the GNU
  5502. C Library, the value is the same as that returned by
  5503. ‘gethostname’; see *note Host Identification::.
  5504. ‘gethostname’ is implemented with a call to ‘uname’.
  5505. ‘char domainname[]’
  5506. This is the NIS or YP domain name. It is the same value
  5507. returned by ‘getdomainname’; see *note Host Identification::.
  5508. This element is a relatively recent invention and use of it is
  5509. not as portable as use of the rest of the structure.
  5510. -- Function: int uname (struct utsname *INFO)
  5511. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5512. Concepts::.
  5513. The ‘uname’ function fills in the structure pointed to by INFO with
  5514. information about the operating system and host machine. A
  5515. non-negative return value indicates that the data was successfully
  5516. stored.
  5517. ‘-1’ as the return value indicates an error. The only error
  5518. possible is ‘EFAULT’, which we normally don’t mention as it is
  5519. always a possibility.
  5520. 
  5521. File: libc.info, Node: Filesystem Handling, Prev: Platform Type, Up: System Management
  5522. 31.3 Controlling and Querying Mounts
  5523. ====================================
  5524. All files are in filesystems, and before you can access any file, its
  5525. filesystem must be mounted. Because of Unix’s concept of _Everything is
  5526. a file_, mounting of filesystems is central to doing almost anything.
  5527. This section explains how to find out what filesystems are currently
  5528. mounted and what filesystems are available for mounting, and how to
  5529. change what is mounted.
  5530. The classic filesystem is the contents of a disk drive. The concept
  5531. is considerably more abstract, though, and lots of things other than
  5532. disk drives can be mounted.
  5533. Some block devices don’t correspond to traditional devices like disk
  5534. drives. For example, a loop device is a block device whose driver uses
  5535. a regular file in another filesystem as its medium. So if that regular
  5536. file contains appropriate data for a filesystem, you can by mounting the
  5537. loop device essentially mount a regular file.
  5538. Some filesystems aren’t based on a device of any kind. The “proc”
  5539. filesystem, for example, contains files whose data is made up by the
  5540. filesystem driver on the fly whenever you ask for it. And when you
  5541. write to it, the data you write causes changes in the system. No data
  5542. gets stored.
  5543. * Menu:
  5544. * Mount Information:: What is or could be mounted?
  5545. * Mount-Unmount-Remount:: Controlling what is mounted and how
  5546. 
  5547. File: libc.info, Node: Mount Information, Next: Mount-Unmount-Remount, Up: Filesystem Handling
  5548. 31.3.1 Mount Information
  5549. ------------------------
  5550. For some programs it is desirable and necessary to access information
  5551. about whether a certain filesystem is mounted and, if it is, where, or
  5552. simply to get lists of all the available filesystems. The GNU C Library
  5553. provides some functions to retrieve this information portably.
  5554. Traditionally Unix systems have a file named ‘/etc/fstab’ which
  5555. describes all possibly mounted filesystems. The ‘mount’ program uses
  5556. this file to mount at startup time of the system all the necessary
  5557. filesystems. The information about all the filesystems actually mounted
  5558. is normally kept in a file named either ‘/var/run/mtab’ or ‘/etc/mtab’.
  5559. Both files share the same syntax and it is crucial that this syntax is
  5560. followed all the time. Therefore it is best to never directly write to
  5561. the files. The functions described in this section can do this and they
  5562. also provide the functionality to convert the external textual
  5563. representation to the internal representation.
  5564. Note that the ‘fstab’ and ‘mtab’ files are maintained on a system by
  5565. _convention_. It is possible for the files not to exist or not to be
  5566. consistent with what is really mounted or available to mount, if the
  5567. system’s administration policy allows it. But programs that mount and
  5568. unmount filesystems typically maintain and use these files as described
  5569. herein.
  5570. The filenames given above should never be used directly. The
  5571. portable way to handle these files is to use the macros ‘_PATH_FSTAB’,
  5572. defined in ‘fstab.h’, or ‘_PATH_MNTTAB’, defined in ‘mntent.h’ and
  5573. ‘paths.h’, for ‘fstab’; and the macro ‘_PATH_MOUNTED’, also defined in
  5574. ‘mntent.h’ and ‘paths.h’, for ‘mtab’. There are also two alternate
  5575. macro names ‘FSTAB’, ‘MNTTAB’, and ‘MOUNTED’ defined but these names are
  5576. deprecated and kept only for backward compatibility. The names
  5577. ‘_PATH_MNTTAB’ and ‘_PATH_MOUNTED’ should always be used.
  5578. * Menu:
  5579. * fstab:: The ‘fstab’ file
  5580. * mtab:: The ‘mtab’ file
  5581. * Other Mount Information:: Other (non-libc) sources of mount information
  5582. 
  5583. File: libc.info, Node: fstab, Next: mtab, Up: Mount Information
  5584. 31.3.1.1 The ‘fstab’ file
  5585. .........................
  5586. The internal representation for entries of the file is ‘struct fstab’,
  5587. defined in ‘fstab.h’.
  5588. -- Data Type: struct fstab
  5589. This structure is used with the ‘getfsent’, ‘getfsspec’, and
  5590. ‘getfsfile’ functions.
  5591. ‘char *fs_spec’
  5592. This element describes the device from which the filesystem is
  5593. mounted. Normally this is the name of a special device, such
  5594. as a hard disk partition, but it could also be a more or less
  5595. generic string. For “NFS” it would be a hostname and
  5596. directory name combination.
  5597. Even though the element is not declared ‘const’ it shouldn’t
  5598. be modified. The missing ‘const’ has historic reasons, since
  5599. this function predates ISO C. The same is true for the other
  5600. string elements of this structure.
  5601. ‘char *fs_file’
  5602. This describes the mount point on the local system. I.e.,
  5603. accessing any file in this filesystem has implicitly or
  5604. explicitly this string as a prefix.
  5605. ‘char *fs_vfstype’
  5606. This is the type of the filesystem. Depending on what the
  5607. underlying kernel understands it can be any string.
  5608. ‘char *fs_mntops’
  5609. This is a string containing options passed to the kernel with
  5610. the ‘mount’ call. Again, this can be almost anything. There
  5611. can be more than one option, separated from the others by a
  5612. comma. Each option consists of a name and an optional value
  5613. part, introduced by an ‘=’ character.
  5614. If the value of this element must be processed it should
  5615. ideally be done using the ‘getsubopt’ function; see *note
  5616. Suboptions::.
  5617. ‘const char *fs_type’
  5618. This name is poorly chosen. This element points to a string
  5619. (possibly in the ‘fs_mntops’ string) which describes the modes
  5620. with which the filesystem is mounted. ‘fstab’ defines five
  5621. macros to describe the possible values:
  5622. ‘FSTAB_RW’
  5623. The filesystem gets mounted with read and write enabled.
  5624. ‘FSTAB_RQ’
  5625. The filesystem gets mounted with read and write enabled.
  5626. Write access is restricted by quotas.
  5627. ‘FSTAB_RO’
  5628. The filesystem gets mounted read-only.
  5629. ‘FSTAB_SW’
  5630. This is not a real filesystem, it is a swap device.
  5631. ‘FSTAB_XX’
  5632. This entry from the ‘fstab’ file is totally ignored.
  5633. Testing for equality with these values must happen using
  5634. ‘strcmp’ since these are all strings. Comparing the pointer
  5635. will probably always fail.
  5636. ‘int fs_freq’
  5637. This element describes the dump frequency in days.
  5638. ‘int fs_passno’
  5639. This element describes the pass number on parallel dumps. It
  5640. is closely related to the ‘dump’ utility used on Unix systems.
  5641. To read the entire content of the of the ‘fstab’ file the GNU C
  5642. Library contains a set of three functions which are designed in the
  5643. usual way.
  5644. -- Function: int setfsent (void)
  5645. Preliminary: | MT-Unsafe race:fsent | AS-Unsafe heap corrupt lock |
  5646. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  5647. This function makes sure that the internal read pointer for the
  5648. ‘fstab’ file is at the beginning of the file. This is done by
  5649. either opening the file or resetting the read pointer.
  5650. Since the file handle is internal to the libc this function is not
  5651. thread-safe.
  5652. This function returns a non-zero value if the operation was
  5653. successful and the ‘getfs*’ functions can be used to read the
  5654. entries of the file.
  5655. -- Function: void endfsent (void)
  5656. Preliminary: | MT-Unsafe race:fsent | AS-Unsafe heap corrupt lock |
  5657. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  5658. This function makes sure that all resources acquired by a prior
  5659. call to ‘setfsent’ (explicitly or implicitly by calling ‘getfsent’)
  5660. are freed.
  5661. -- Function: struct fstab * getfsent (void)
  5662. Preliminary: | MT-Unsafe race:fsent locale | AS-Unsafe corrupt heap
  5663. lock | AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5664. This function returns the next entry of the ‘fstab’ file. If this
  5665. is the first call to any of the functions handling ‘fstab’ since
  5666. program start or the last call of ‘endfsent’, the file will be
  5667. opened.
  5668. The function returns a pointer to a variable of type ‘struct
  5669. fstab’. This variable is shared by all threads and therefore this
  5670. function is not thread-safe. If an error occurred ‘getfsent’
  5671. returns a ‘NULL’ pointer.
  5672. -- Function: struct fstab * getfsspec (const char *NAME)
  5673. Preliminary: | MT-Unsafe race:fsent locale | AS-Unsafe corrupt heap
  5674. lock | AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5675. This function returns the next entry of the ‘fstab’ file which has
  5676. a string equal to NAME pointed to by the ‘fs_spec’ element. Since
  5677. there is normally exactly one entry for each special device it
  5678. makes no sense to call this function more than once for the same
  5679. argument. If this is the first call to any of the functions
  5680. handling ‘fstab’ since program start or the last call of
  5681. ‘endfsent’, the file will be opened.
  5682. The function returns a pointer to a variable of type ‘struct
  5683. fstab’. This variable is shared by all threads and therefore this
  5684. function is not thread-safe. If an error occurred ‘getfsent’
  5685. returns a ‘NULL’ pointer.
  5686. -- Function: struct fstab * getfsfile (const char *NAME)
  5687. Preliminary: | MT-Unsafe race:fsent locale | AS-Unsafe corrupt heap
  5688. lock | AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5689. This function returns the next entry of the ‘fstab’ file which has
  5690. a string equal to NAME pointed to by the ‘fs_file’ element. Since
  5691. there is normally exactly one entry for each mount point it makes
  5692. no sense to call this function more than once for the same
  5693. argument. If this is the first call to any of the functions
  5694. handling ‘fstab’ since program start or the last call of
  5695. ‘endfsent’, the file will be opened.
  5696. The function returns a pointer to a variable of type ‘struct
  5697. fstab’. This variable is shared by all threads and therefore this
  5698. function is not thread-safe. If an error occurred ‘getfsent’
  5699. returns a ‘NULL’ pointer.
  5700. 
  5701. File: libc.info, Node: mtab, Next: Other Mount Information, Prev: fstab, Up: Mount Information
  5702. 31.3.1.2 The ‘mtab’ file
  5703. ........................
  5704. The following functions and data structure access the ‘mtab’ file.
  5705. -- Data Type: struct mntent
  5706. This structure is used with the ‘getmntent’, ‘getmntent_r’,
  5707. ‘addmntent’, and ‘hasmntopt’ functions.
  5708. ‘char *mnt_fsname’
  5709. This element contains a pointer to a string describing the
  5710. name of the special device from which the filesystem is
  5711. mounted. It corresponds to the ‘fs_spec’ element in ‘struct
  5712. fstab’.
  5713. ‘char *mnt_dir’
  5714. This element points to a string describing the mount point of
  5715. the filesystem. It corresponds to the ‘fs_file’ element in
  5716. ‘struct fstab’.
  5717. ‘char *mnt_type’
  5718. ‘mnt_type’ describes the filesystem type and is therefore
  5719. equivalent to ‘fs_vfstype’ in ‘struct fstab’. ‘mntent.h’
  5720. defines a few symbolic names for some of the values this
  5721. string can have. But since the kernel can support arbitrary
  5722. filesystems it does not make much sense to give them symbolic
  5723. names. If one knows the symbol name one also knows the
  5724. filesystem name. Nevertheless here follows the list of the
  5725. symbols provided in ‘mntent.h’.
  5726. ‘MNTTYPE_IGNORE’
  5727. This symbol expands to ‘"ignore"’. The value is
  5728. sometimes used in ‘fstab’ files to make sure entries are
  5729. not used without removing them.
  5730. ‘MNTTYPE_NFS’
  5731. Expands to ‘"nfs"’. Using this macro sometimes could
  5732. make sense since it names the default NFS implementation,
  5733. in case both version 2 and 3 are supported.
  5734. ‘MNTTYPE_SWAP’
  5735. This symbol expands to ‘"swap"’. It names the special
  5736. ‘fstab’ entry which names one of the possibly multiple
  5737. swap partitions.
  5738. ‘char *mnt_opts’
  5739. The element contains a string describing the options used
  5740. while mounting the filesystem. As for the equivalent element
  5741. ‘fs_mntops’ of ‘struct fstab’ it is best to use the function
  5742. ‘getsubopt’ (*note Suboptions::) to access the parts of this
  5743. string.
  5744. The ‘mntent.h’ file defines a number of macros with string
  5745. values which correspond to some of the options understood by
  5746. the kernel. There might be many more options which are
  5747. possible so it doesn’t make much sense to rely on these macros
  5748. but to be consistent here is the list:
  5749. ‘MNTOPT_DEFAULTS’
  5750. Expands to ‘"defaults"’. This option should be used
  5751. alone since it indicates all values for the customizable
  5752. values are chosen to be the default.
  5753. ‘MNTOPT_RO’
  5754. Expands to ‘"ro"’. See the ‘FSTAB_RO’ value, it means
  5755. the filesystem is mounted read-only.
  5756. ‘MNTOPT_RW’
  5757. Expands to ‘"rw"’. See the ‘FSTAB_RW’ value, it means
  5758. the filesystem is mounted with read and write
  5759. permissions.
  5760. ‘MNTOPT_SUID’
  5761. Expands to ‘"suid"’. This means that the SUID bit (*note
  5762. How Change Persona::) is respected when a program from
  5763. the filesystem is started.
  5764. ‘MNTOPT_NOSUID’
  5765. Expands to ‘"nosuid"’. This is the opposite of
  5766. ‘MNTOPT_SUID’, the SUID bit for all files from the
  5767. filesystem is ignored.
  5768. ‘MNTOPT_NOAUTO’
  5769. Expands to ‘"noauto"’. At startup time the ‘mount’
  5770. program will ignore this entry if it is started with the
  5771. ‘-a’ option to mount all filesystems mentioned in the
  5772. ‘fstab’ file.
  5773. As for the ‘FSTAB_*’ entries introduced above it is important
  5774. to use ‘strcmp’ to check for equality.
  5775. ‘mnt_freq’
  5776. This elements corresponds to ‘fs_freq’ and also specifies the
  5777. frequency in days in which dumps are made.
  5778. ‘mnt_passno’
  5779. This element is equivalent to ‘fs_passno’ with the same
  5780. meaning which is uninteresting for all programs beside ‘dump’.
  5781. For accessing the ‘mtab’ file there is again a set of three functions
  5782. to access all entries in a row. Unlike the functions to handle ‘fstab’
  5783. these functions do not access a fixed file and there is even a thread
  5784. safe variant of the get function. Besides this the GNU C Library
  5785. contains functions to alter the file and test for specific options.
  5786. -- Function: FILE * setmntent (const char *FILE, const char *MODE)
  5787. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem fd
  5788. lock | *Note POSIX Safety Concepts::.
  5789. The ‘setmntent’ function prepares the file named FILE which must be
  5790. in the format of a ‘fstab’ and ‘mtab’ file for the upcoming
  5791. processing through the other functions of the family. The MODE
  5792. parameter can be chosen in the way the OPENTYPE parameter for
  5793. ‘fopen’ (*note Opening Streams::) can be chosen. If the file is
  5794. opened for writing the file is also allowed to be empty.
  5795. If the file was successfully opened ‘setmntent’ returns a file
  5796. handle for future use. Otherwise the return value is ‘NULL’ and
  5797. ‘errno’ is set accordingly.
  5798. -- Function: int endmntent (FILE *STREAM)
  5799. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock mem
  5800. fd | *Note POSIX Safety Concepts::.
  5801. This function takes for the STREAM parameter a file handle which
  5802. previously was returned from the ‘setmntent’ call. ‘endmntent’
  5803. closes the stream and frees all resources.
  5804. The return value is 1 unless an error occurred in which case it is
  5805. 0.
  5806. -- Function: struct mntent * getmntent (FILE *STREAM)
  5807. Preliminary: | MT-Unsafe race:mntentbuf locale | AS-Unsafe corrupt
  5808. heap init | AC-Unsafe init corrupt lock mem | *Note POSIX Safety
  5809. Concepts::.
  5810. The ‘getmntent’ function takes as the parameter a file handle
  5811. previously returned by a successful call to ‘setmntent’. It
  5812. returns a pointer to a static variable of type ‘struct mntent’
  5813. which is filled with the information from the next entry from the
  5814. file currently read.
  5815. The file format used prescribes the use of spaces or tab characters
  5816. to separate the fields. This makes it harder to use names
  5817. containing one of these characters (e.g., mount points using
  5818. spaces). Therefore these characters are encoded in the files and
  5819. the ‘getmntent’ function takes care of the decoding while reading
  5820. the entries back in. ‘'\040'’ is used to encode a space character,
  5821. ‘'\011'’ to encode a tab character, ‘'\012'’ to encode a newline
  5822. character, and ‘'\\'’ to encode a backslash.
  5823. If there was an error or the end of the file is reached the return
  5824. value is ‘NULL’.
  5825. This function is not thread-safe since all calls to this function
  5826. return a pointer to the same static variable. ‘getmntent_r’ should
  5827. be used in situations where multiple threads access the file.
  5828. -- Function: struct mntent * getmntent_r (FILE *STREAM, struct mntent
  5829. *RESULT, char *BUFFER, int BUFSIZE)
  5830. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  5831. corrupt lock mem | *Note POSIX Safety Concepts::.
  5832. The ‘getmntent_r’ function is the reentrant variant of ‘getmntent’.
  5833. It also returns the next entry from the file and returns a pointer.
  5834. The actual variable the values are stored in is not static, though.
  5835. Instead the function stores the values in the variable pointed to
  5836. by the RESULT parameter. Additional information (e.g., the strings
  5837. pointed to by the elements of the result) are kept in the buffer of
  5838. size BUFSIZE pointed to by BUFFER.
  5839. Escaped characters (space, tab, backslash) are converted back in
  5840. the same way as it happens for ‘getmentent’.
  5841. The function returns a ‘NULL’ pointer in error cases. Errors could
  5842. be:
  5843. • error while reading the file,
  5844. • end of file reached,
  5845. • BUFSIZE is too small for reading a complete new entry.
  5846. -- Function: int addmntent (FILE *STREAM, const struct mntent *MNT)
  5847. Preliminary: | MT-Safe race:stream locale | AS-Unsafe corrupt |
  5848. AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  5849. The ‘addmntent’ function allows adding a new entry to the file
  5850. previously opened with ‘setmntent’. The new entries are always
  5851. appended. I.e., even if the position of the file descriptor is not
  5852. at the end of the file this function does not overwrite an existing
  5853. entry following the current position.
  5854. The implication of this is that to remove an entry from a file one
  5855. has to create a new file while leaving out the entry to be removed
  5856. and after closing the file remove the old one and rename the new
  5857. file to the chosen name.
  5858. This function takes care of spaces and tab characters in the names
  5859. to be written to the file. It converts them and the backslash
  5860. character into the format described in the ‘getmntent’ description
  5861. above.
  5862. This function returns 0 in case the operation was successful.
  5863. Otherwise the return value is 1 and ‘errno’ is set appropriately.
  5864. -- Function: char * hasmntopt (const struct mntent *MNT, const char
  5865. *OPT)
  5866. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5867. Concepts::.
  5868. This function can be used to check whether the string pointed to by
  5869. the ‘mnt_opts’ element of the variable pointed to by MNT contains
  5870. the option OPT. If this is true a pointer to the beginning of the
  5871. option in the ‘mnt_opts’ element is returned. If no such option
  5872. exists the function returns ‘NULL’.
  5873. This function is useful to test whether a specific option is
  5874. present but when all options have to be processed one is better off
  5875. with using the ‘getsubopt’ function to iterate over all options in
  5876. the string.
  5877. 
  5878. File: libc.info, Node: Other Mount Information, Prev: mtab, Up: Mount Information
  5879. 31.3.1.3 Other (Non-libc) Sources of Mount Information
  5880. ......................................................
  5881. On a system with a Linux kernel and the ‘proc’ filesystem, you can get
  5882. information on currently mounted filesystems from the file ‘mounts’ in
  5883. the ‘proc’ filesystem. Its format is similar to that of the ‘mtab’
  5884. file, but represents what is truly mounted without relying on facilities
  5885. outside the kernel to keep ‘mtab’ up to date.
  5886. 
  5887. File: libc.info, Node: Mount-Unmount-Remount, Prev: Mount Information, Up: Filesystem Handling
  5888. 31.3.2 Mount, Unmount, Remount
  5889. ------------------------------
  5890. This section describes the functions for mounting, unmounting, and
  5891. remounting filesystems.
  5892. Only the superuser can mount, unmount, or remount a filesystem.
  5893. These functions do not access the ‘fstab’ and ‘mtab’ files. You
  5894. should maintain and use these separately. *Note Mount Information::.
  5895. The symbols in this section are declared in ‘sys/mount.h’.
  5896. -- Function: int mount (const char *SPECIAL_FILE, const char *DIR,
  5897. const char *FSTYPE, unsigned long int OPTIONS, const void
  5898. *DATA)
  5899. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5900. Concepts::.
  5901. ‘mount’ mounts or remounts a filesystem. The two operations are
  5902. quite different and are merged rather unnaturally into this one
  5903. function. The ‘MS_REMOUNT’ option, explained below, determines
  5904. whether ‘mount’ mounts or remounts.
  5905. For a mount, the filesystem on the block device represented by the
  5906. device special file named SPECIAL_FILE gets mounted over the mount
  5907. point DIR. This means that the directory DIR (along with any files
  5908. in it) is no longer visible; in its place (and still with the name
  5909. DIR) is the root directory of the filesystem on the device.
  5910. As an exception, if the filesystem type (see below) is one which is
  5911. not based on a device (e.g. “proc”), ‘mount’ instantiates a
  5912. filesystem and mounts it over DIR and ignores SPECIAL_FILE.
  5913. For a remount, DIR specifies the mount point where the filesystem
  5914. to be remounted is (and remains) mounted and SPECIAL_FILE is
  5915. ignored. Remounting a filesystem means changing the options that
  5916. control operations on the filesystem while it is mounted. It does
  5917. not mean unmounting and mounting again.
  5918. For a mount, you must identify the type of the filesystem with
  5919. FSTYPE. This type tells the kernel how to access the filesystem
  5920. and can be thought of as the name of a filesystem driver. The
  5921. acceptable values are system dependent. On a system with a Linux
  5922. kernel and the ‘proc’ filesystem, the list of possible values is in
  5923. the file ‘filesystems’ in the ‘proc’ filesystem (e.g. type ‘cat
  5924. /proc/filesystems’ to see the list). With a Linux kernel, the
  5925. types of filesystems that ‘mount’ can mount, and their type names,
  5926. depends on what filesystem drivers are configured into the kernel
  5927. or loaded as loadable kernel modules. An example of a common value
  5928. for FSTYPE is ‘ext2’.
  5929. For a remount, ‘mount’ ignores FSTYPE.
  5930. OPTIONS specifies a variety of options that apply until the
  5931. filesystem is unmounted or remounted. The precise meaning of an
  5932. option depends on the filesystem and with some filesystems, an
  5933. option may have no effect at all. Furthermore, for some
  5934. filesystems, some of these options (but never ‘MS_RDONLY’) can be
  5935. overridden for individual file accesses via ‘ioctl’.
  5936. OPTIONS is a bit string with bit fields defined using the following
  5937. mask and masked value macros:
  5938. ‘MS_MGC_MASK’
  5939. This multibit field contains a magic number. If it does not
  5940. have the value ‘MS_MGC_VAL’, ‘mount’ assumes all the following
  5941. bits are zero and the DATA argument is a null string,
  5942. regardless of their actual values.
  5943. ‘MS_REMOUNT’
  5944. This bit on means to remount the filesystem. Off means to
  5945. mount it.
  5946. ‘MS_RDONLY’
  5947. This bit on specifies that no writing to the filesystem shall
  5948. be allowed while it is mounted. This cannot be overridden by
  5949. ‘ioctl’. This option is available on nearly all filesystems.
  5950. ‘MS_NOSUID’
  5951. This bit on specifies that Setuid and Setgid permissions on
  5952. files in the filesystem shall be ignored while it is mounted.
  5953. ‘MS_NOEXEC’
  5954. This bit on specifies that no files in the filesystem shall be
  5955. executed while the filesystem is mounted.
  5956. ‘MS_NODEV’
  5957. This bit on specifies that no device special files in the
  5958. filesystem shall be accessible while the filesystem is
  5959. mounted.
  5960. ‘MS_SYNCHRONOUS’
  5961. This bit on specifies that all writes to the filesystem while
  5962. it is mounted shall be synchronous; i.e., data shall be synced
  5963. before each write completes rather than held in the buffer
  5964. cache.
  5965. ‘MS_MANDLOCK’
  5966. This bit on specifies that mandatory locks on files shall be
  5967. permitted while the filesystem is mounted.
  5968. ‘MS_NOATIME’
  5969. This bit on specifies that access times of files shall not be
  5970. updated when the files are accessed while the filesystem is
  5971. mounted.
  5972. ‘MS_NODIRATIME’
  5973. This bit on specifies that access times of directories shall
  5974. not be updated when the directories are accessed while the
  5975. filesystem in mounted.
  5976. Any bits not covered by the above masks should be set off;
  5977. otherwise, results are undefined.
  5978. The meaning of DATA depends on the filesystem type and is
  5979. controlled entirely by the filesystem driver in the kernel.
  5980. Example:
  5981. #include <sys/mount.h>
  5982. mount("/dev/hdb", "/cdrom", "iso9660", MS_MGC_VAL | MS_RDONLY | MS_NOSUID, "");
  5983. mount("/dev/hda2", "/mnt", "", MS_MGC_VAL | MS_REMOUNT, "");
  5984. Appropriate arguments for ‘mount’ are conventionally recorded in
  5985. the ‘fstab’ table. *Note Mount Information::.
  5986. The return value is zero if the mount or remount is successful.
  5987. Otherwise, it is ‘-1’ and ‘errno’ is set appropriately. The values
  5988. of ‘errno’ are filesystem dependent, but here is a general list:
  5989. ‘EPERM’
  5990. The process is not superuser.
  5991. ‘ENODEV’
  5992. The file system type FSTYPE is not known to the kernel.
  5993. ‘ENOTBLK’
  5994. The file DEV is not a block device special file.
  5995. ‘EBUSY’
  5996. • The device is already mounted.
  5997. • The mount point is busy. (E.g. it is some process’
  5998. working directory or has a filesystem mounted on it
  5999. already).
  6000. • The request is to remount read-only, but there are files
  6001. open for writing.
  6002. ‘EINVAL’
  6003. • A remount was attempted, but there is no filesystem
  6004. mounted over the specified mount point.
  6005. • The supposed filesystem has an invalid superblock.
  6006. ‘EACCES’
  6007. • The filesystem is inherently read-only (possibly due to a
  6008. switch on the device) and the process attempted to mount
  6009. it read/write (by setting the ‘MS_RDONLY’ bit off).
  6010. • SPECIAL_FILE or DIR is not accessible due to file
  6011. permissions.
  6012. • SPECIAL_FILE is not accessible because it is in a
  6013. filesystem that is mounted with the ‘MS_NODEV’ option.
  6014. ‘EM_FILE’
  6015. The table of dummy devices is full. ‘mount’ needs to create a
  6016. dummy device (aka “unnamed” device) if the filesystem being
  6017. mounted is not one that uses a device.
  6018. -- Function: int umount2 (const char *FILE, int FLAGS)
  6019. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6020. Concepts::.
  6021. ‘umount2’ unmounts a filesystem.
  6022. You can identify the filesystem to unmount either by the device
  6023. special file that contains the filesystem or by the mount point.
  6024. The effect is the same. Specify either as the string FILE.
  6025. FLAGS contains the one-bit field identified by the following mask
  6026. macro:
  6027. ‘MNT_FORCE’
  6028. This bit on means to force the unmounting even if the
  6029. filesystem is busy, by making it unbusy first. If the bit is
  6030. off and the filesystem is busy, ‘umount2’ fails with ‘errno’ =
  6031. ‘EBUSY’. Depending on the filesystem, this may override all,
  6032. some, or no busy conditions.
  6033. All other bits in FLAGS should be set to zero; otherwise, the
  6034. result is undefined.
  6035. Example:
  6036. #include <sys/mount.h>
  6037. umount2("/mnt", MNT_FORCE);
  6038. umount2("/dev/hdd1", 0);
  6039. After the filesystem is unmounted, the directory that was the mount
  6040. point is visible, as are any files in it.
  6041. As part of unmounting, ‘umount2’ syncs the filesystem.
  6042. If the unmounting is successful, the return value is zero.
  6043. Otherwise, it is ‘-1’ and ‘errno’ is set accordingly:
  6044. ‘EPERM’
  6045. The process is not superuser.
  6046. ‘EBUSY’
  6047. The filesystem cannot be unmounted because it is busy. E.g.
  6048. it contains a directory that is some process’s working
  6049. directory or a file that some process has open. With some
  6050. filesystems in some cases, you can avoid this failure with the
  6051. ‘MNT_FORCE’ option.
  6052. ‘EINVAL’
  6053. FILE validly refers to a file, but that file is neither a
  6054. mount point nor a device special file of a currently mounted
  6055. filesystem.
  6056. This function is not available on all systems.
  6057. -- Function: int umount (const char *FILE)
  6058. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  6059. Concepts::.
  6060. ‘umount’ does the same thing as ‘umount2’ with FLAGS set to zeroes.
  6061. It is more widely available than ‘umount2’ but since it lacks the
  6062. possibility to forcefully unmount a filesystem is deprecated when
  6063. ‘umount2’ is also available.