libc.info-11 301 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586
  1. This is libc.info, produced by makeinfo version 5.2 from libc.texinfo.
  2. This file documents the GNU C Library.
  3. This is ‘The GNU C Library Reference Manual’, for version 2.25.
  4. Copyright © 1993–2017 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with the
  8. Invariant Sections being “Free Software Needs Free Documentation” and
  9. “GNU Lesser General Public License”, the Front-Cover texts being “A GNU
  10. Manual”, and with the Back-Cover Texts as in (a) below. A copy of the
  11. license is included in the section entitled "GNU Free Documentation
  12. License".
  13. (a) The FSF’s Back-Cover Text is: “You have the freedom to copy and
  14. modify this GNU manual. Buying copies from the FSF supports it in
  15. developing GNU and promoting software freedom.”
  16. INFO-DIR-SECTION Software libraries
  17. START-INFO-DIR-ENTRY
  18. * Libc: (libc). C library.
  19. END-INFO-DIR-ENTRY
  20. INFO-DIR-SECTION GNU C library functions and macros
  21. START-INFO-DIR-ENTRY
  22. * a64l: (libc)Encode Binary Data.
  23. * abort: (libc)Aborting a Program.
  24. * abs: (libc)Absolute Value.
  25. * accept: (libc)Accepting Connections.
  26. * access: (libc)Testing File Access.
  27. * acosf: (libc)Inverse Trig Functions.
  28. * acoshf: (libc)Hyperbolic Functions.
  29. * acosh: (libc)Hyperbolic Functions.
  30. * acoshl: (libc)Hyperbolic Functions.
  31. * acos: (libc)Inverse Trig Functions.
  32. * acosl: (libc)Inverse Trig Functions.
  33. * addmntent: (libc)mtab.
  34. * addseverity: (libc)Adding Severity Classes.
  35. * adjtime: (libc)High-Resolution Calendar.
  36. * adjtimex: (libc)High-Resolution Calendar.
  37. * aio_cancel64: (libc)Cancel AIO Operations.
  38. * aio_cancel: (libc)Cancel AIO Operations.
  39. * aio_error64: (libc)Status of AIO Operations.
  40. * aio_error: (libc)Status of AIO Operations.
  41. * aio_fsync64: (libc)Synchronizing AIO Operations.
  42. * aio_fsync: (libc)Synchronizing AIO Operations.
  43. * aio_init: (libc)Configuration of AIO.
  44. * aio_read64: (libc)Asynchronous Reads/Writes.
  45. * aio_read: (libc)Asynchronous Reads/Writes.
  46. * aio_return64: (libc)Status of AIO Operations.
  47. * aio_return: (libc)Status of AIO Operations.
  48. * aio_suspend64: (libc)Synchronizing AIO Operations.
  49. * aio_suspend: (libc)Synchronizing AIO Operations.
  50. * aio_write64: (libc)Asynchronous Reads/Writes.
  51. * aio_write: (libc)Asynchronous Reads/Writes.
  52. * alarm: (libc)Setting an Alarm.
  53. * aligned_alloc: (libc)Aligned Memory Blocks.
  54. * alloca: (libc)Variable Size Automatic.
  55. * alphasort64: (libc)Scanning Directory Content.
  56. * alphasort: (libc)Scanning Directory Content.
  57. * ALTWERASE: (libc)Local Modes.
  58. * ARG_MAX: (libc)General Limits.
  59. * argp_error: (libc)Argp Helper Functions.
  60. * ARGP_ERR_UNKNOWN: (libc)Argp Parser Functions.
  61. * argp_failure: (libc)Argp Helper Functions.
  62. * argp_help: (libc)Argp Help.
  63. * argp_parse: (libc)Argp.
  64. * argp_state_help: (libc)Argp Helper Functions.
  65. * argp_usage: (libc)Argp Helper Functions.
  66. * argz_add: (libc)Argz Functions.
  67. * argz_add_sep: (libc)Argz Functions.
  68. * argz_append: (libc)Argz Functions.
  69. * argz_count: (libc)Argz Functions.
  70. * argz_create: (libc)Argz Functions.
  71. * argz_create_sep: (libc)Argz Functions.
  72. * argz_delete: (libc)Argz Functions.
  73. * argz_extract: (libc)Argz Functions.
  74. * argz_insert: (libc)Argz Functions.
  75. * argz_next: (libc)Argz Functions.
  76. * argz_replace: (libc)Argz Functions.
  77. * argz_stringify: (libc)Argz Functions.
  78. * asctime: (libc)Formatting Calendar Time.
  79. * asctime_r: (libc)Formatting Calendar Time.
  80. * asinf: (libc)Inverse Trig Functions.
  81. * asinhf: (libc)Hyperbolic Functions.
  82. * asinh: (libc)Hyperbolic Functions.
  83. * asinhl: (libc)Hyperbolic Functions.
  84. * asin: (libc)Inverse Trig Functions.
  85. * asinl: (libc)Inverse Trig Functions.
  86. * asprintf: (libc)Dynamic Output.
  87. * assert: (libc)Consistency Checking.
  88. * assert_perror: (libc)Consistency Checking.
  89. * atan2f: (libc)Inverse Trig Functions.
  90. * atan2: (libc)Inverse Trig Functions.
  91. * atan2l: (libc)Inverse Trig Functions.
  92. * atanf: (libc)Inverse Trig Functions.
  93. * atanhf: (libc)Hyperbolic Functions.
  94. * atanh: (libc)Hyperbolic Functions.
  95. * atanhl: (libc)Hyperbolic Functions.
  96. * atan: (libc)Inverse Trig Functions.
  97. * atanl: (libc)Inverse Trig Functions.
  98. * atexit: (libc)Cleanups on Exit.
  99. * atof: (libc)Parsing of Floats.
  100. * atoi: (libc)Parsing of Integers.
  101. * atol: (libc)Parsing of Integers.
  102. * atoll: (libc)Parsing of Integers.
  103. * backtrace: (libc)Backtraces.
  104. * backtrace_symbols_fd: (libc)Backtraces.
  105. * backtrace_symbols: (libc)Backtraces.
  106. * basename: (libc)Finding Tokens in a String.
  107. * basename: (libc)Finding Tokens in a String.
  108. * BC_BASE_MAX: (libc)Utility Limits.
  109. * BC_DIM_MAX: (libc)Utility Limits.
  110. * bcmp: (libc)String/Array Comparison.
  111. * bcopy: (libc)Copying Strings and Arrays.
  112. * BC_SCALE_MAX: (libc)Utility Limits.
  113. * BC_STRING_MAX: (libc)Utility Limits.
  114. * bind: (libc)Setting Address.
  115. * bind_textdomain_codeset: (libc)Charset conversion in gettext.
  116. * bindtextdomain: (libc)Locating gettext catalog.
  117. * BRKINT: (libc)Input Modes.
  118. * brk: (libc)Resizing the Data Segment.
  119. * bsearch: (libc)Array Search Function.
  120. * btowc: (libc)Converting a Character.
  121. * BUFSIZ: (libc)Controlling Buffering.
  122. * bzero: (libc)Copying Strings and Arrays.
  123. * cabsf: (libc)Absolute Value.
  124. * cabs: (libc)Absolute Value.
  125. * cabsl: (libc)Absolute Value.
  126. * cacosf: (libc)Inverse Trig Functions.
  127. * cacoshf: (libc)Hyperbolic Functions.
  128. * cacosh: (libc)Hyperbolic Functions.
  129. * cacoshl: (libc)Hyperbolic Functions.
  130. * cacos: (libc)Inverse Trig Functions.
  131. * cacosl: (libc)Inverse Trig Functions.
  132. * calloc: (libc)Allocating Cleared Space.
  133. * canonicalize_file_name: (libc)Symbolic Links.
  134. * canonicalizef: (libc)FP Bit Twiddling.
  135. * canonicalize: (libc)FP Bit Twiddling.
  136. * canonicalizel: (libc)FP Bit Twiddling.
  137. * cargf: (libc)Operations on Complex.
  138. * carg: (libc)Operations on Complex.
  139. * cargl: (libc)Operations on Complex.
  140. * casinf: (libc)Inverse Trig Functions.
  141. * casinhf: (libc)Hyperbolic Functions.
  142. * casinh: (libc)Hyperbolic Functions.
  143. * casinhl: (libc)Hyperbolic Functions.
  144. * casin: (libc)Inverse Trig Functions.
  145. * casinl: (libc)Inverse Trig Functions.
  146. * catanf: (libc)Inverse Trig Functions.
  147. * catanhf: (libc)Hyperbolic Functions.
  148. * catanh: (libc)Hyperbolic Functions.
  149. * catanhl: (libc)Hyperbolic Functions.
  150. * catan: (libc)Inverse Trig Functions.
  151. * catanl: (libc)Inverse Trig Functions.
  152. * catclose: (libc)The catgets Functions.
  153. * catgets: (libc)The catgets Functions.
  154. * catopen: (libc)The catgets Functions.
  155. * cbc_crypt: (libc)DES Encryption.
  156. * cbrtf: (libc)Exponents and Logarithms.
  157. * cbrt: (libc)Exponents and Logarithms.
  158. * cbrtl: (libc)Exponents and Logarithms.
  159. * ccosf: (libc)Trig Functions.
  160. * ccoshf: (libc)Hyperbolic Functions.
  161. * ccosh: (libc)Hyperbolic Functions.
  162. * ccoshl: (libc)Hyperbolic Functions.
  163. * ccos: (libc)Trig Functions.
  164. * ccosl: (libc)Trig Functions.
  165. * CCTS_OFLOW: (libc)Control Modes.
  166. * ceilf: (libc)Rounding Functions.
  167. * ceil: (libc)Rounding Functions.
  168. * ceill: (libc)Rounding Functions.
  169. * cexpf: (libc)Exponents and Logarithms.
  170. * cexp: (libc)Exponents and Logarithms.
  171. * cexpl: (libc)Exponents and Logarithms.
  172. * cfgetispeed: (libc)Line Speed.
  173. * cfgetospeed: (libc)Line Speed.
  174. * cfmakeraw: (libc)Noncanonical Input.
  175. * cfree: (libc)Freeing after Malloc.
  176. * cfsetispeed: (libc)Line Speed.
  177. * cfsetospeed: (libc)Line Speed.
  178. * cfsetspeed: (libc)Line Speed.
  179. * chdir: (libc)Working Directory.
  180. * CHILD_MAX: (libc)General Limits.
  181. * chmod: (libc)Setting Permissions.
  182. * chown: (libc)File Owner.
  183. * CIGNORE: (libc)Control Modes.
  184. * cimagf: (libc)Operations on Complex.
  185. * cimag: (libc)Operations on Complex.
  186. * cimagl: (libc)Operations on Complex.
  187. * clearenv: (libc)Environment Access.
  188. * clearerr: (libc)Error Recovery.
  189. * clearerr_unlocked: (libc)Error Recovery.
  190. * CLK_TCK: (libc)Processor Time.
  191. * CLOCAL: (libc)Control Modes.
  192. * clock: (libc)CPU Time.
  193. * CLOCKS_PER_SEC: (libc)CPU Time.
  194. * clog10f: (libc)Exponents and Logarithms.
  195. * clog10: (libc)Exponents and Logarithms.
  196. * clog10l: (libc)Exponents and Logarithms.
  197. * clogf: (libc)Exponents and Logarithms.
  198. * clog: (libc)Exponents and Logarithms.
  199. * clogl: (libc)Exponents and Logarithms.
  200. * closedir: (libc)Reading/Closing Directory.
  201. * close: (libc)Opening and Closing Files.
  202. * closelog: (libc)closelog.
  203. * COLL_WEIGHTS_MAX: (libc)Utility Limits.
  204. * _Complex_I: (libc)Complex Numbers.
  205. * confstr: (libc)String Parameters.
  206. * conjf: (libc)Operations on Complex.
  207. * conj: (libc)Operations on Complex.
  208. * conjl: (libc)Operations on Complex.
  209. * connect: (libc)Connecting.
  210. * copysignf: (libc)FP Bit Twiddling.
  211. * copysign: (libc)FP Bit Twiddling.
  212. * copysignl: (libc)FP Bit Twiddling.
  213. * cosf: (libc)Trig Functions.
  214. * coshf: (libc)Hyperbolic Functions.
  215. * cosh: (libc)Hyperbolic Functions.
  216. * coshl: (libc)Hyperbolic Functions.
  217. * cos: (libc)Trig Functions.
  218. * cosl: (libc)Trig Functions.
  219. * cpowf: (libc)Exponents and Logarithms.
  220. * cpow: (libc)Exponents and Logarithms.
  221. * cpowl: (libc)Exponents and Logarithms.
  222. * cprojf: (libc)Operations on Complex.
  223. * cproj: (libc)Operations on Complex.
  224. * cprojl: (libc)Operations on Complex.
  225. * CPU_CLR: (libc)CPU Affinity.
  226. * CPU_ISSET: (libc)CPU Affinity.
  227. * CPU_SET: (libc)CPU Affinity.
  228. * CPU_SETSIZE: (libc)CPU Affinity.
  229. * CPU_ZERO: (libc)CPU Affinity.
  230. * CREAD: (libc)Control Modes.
  231. * crealf: (libc)Operations on Complex.
  232. * creal: (libc)Operations on Complex.
  233. * creall: (libc)Operations on Complex.
  234. * creat64: (libc)Opening and Closing Files.
  235. * creat: (libc)Opening and Closing Files.
  236. * CRTS_IFLOW: (libc)Control Modes.
  237. * crypt: (libc)crypt.
  238. * crypt_r: (libc)crypt.
  239. * CS5: (libc)Control Modes.
  240. * CS6: (libc)Control Modes.
  241. * CS7: (libc)Control Modes.
  242. * CS8: (libc)Control Modes.
  243. * csinf: (libc)Trig Functions.
  244. * csinhf: (libc)Hyperbolic Functions.
  245. * csinh: (libc)Hyperbolic Functions.
  246. * csinhl: (libc)Hyperbolic Functions.
  247. * csin: (libc)Trig Functions.
  248. * csinl: (libc)Trig Functions.
  249. * CSIZE: (libc)Control Modes.
  250. * csqrtf: (libc)Exponents and Logarithms.
  251. * csqrt: (libc)Exponents and Logarithms.
  252. * csqrtl: (libc)Exponents and Logarithms.
  253. * CSTOPB: (libc)Control Modes.
  254. * ctanf: (libc)Trig Functions.
  255. * ctanhf: (libc)Hyperbolic Functions.
  256. * ctanh: (libc)Hyperbolic Functions.
  257. * ctanhl: (libc)Hyperbolic Functions.
  258. * ctan: (libc)Trig Functions.
  259. * ctanl: (libc)Trig Functions.
  260. * ctermid: (libc)Identifying the Terminal.
  261. * ctime: (libc)Formatting Calendar Time.
  262. * ctime_r: (libc)Formatting Calendar Time.
  263. * cuserid: (libc)Who Logged In.
  264. * dcgettext: (libc)Translation with gettext.
  265. * dcngettext: (libc)Advanced gettext functions.
  266. * DES_FAILED: (libc)DES Encryption.
  267. * des_setparity: (libc)DES Encryption.
  268. * dgettext: (libc)Translation with gettext.
  269. * difftime: (libc)Elapsed Time.
  270. * dirfd: (libc)Opening a Directory.
  271. * dirname: (libc)Finding Tokens in a String.
  272. * div: (libc)Integer Division.
  273. * dngettext: (libc)Advanced gettext functions.
  274. * drand48: (libc)SVID Random.
  275. * drand48_r: (libc)SVID Random.
  276. * dremf: (libc)Remainder Functions.
  277. * drem: (libc)Remainder Functions.
  278. * dreml: (libc)Remainder Functions.
  279. * DTTOIF: (libc)Directory Entries.
  280. * dup2: (libc)Duplicating Descriptors.
  281. * dup: (libc)Duplicating Descriptors.
  282. * E2BIG: (libc)Error Codes.
  283. * EACCES: (libc)Error Codes.
  284. * EADDRINUSE: (libc)Error Codes.
  285. * EADDRNOTAVAIL: (libc)Error Codes.
  286. * EADV: (libc)Error Codes.
  287. * EAFNOSUPPORT: (libc)Error Codes.
  288. * EAGAIN: (libc)Error Codes.
  289. * EALREADY: (libc)Error Codes.
  290. * EAUTH: (libc)Error Codes.
  291. * EBACKGROUND: (libc)Error Codes.
  292. * EBADE: (libc)Error Codes.
  293. * EBADFD: (libc)Error Codes.
  294. * EBADF: (libc)Error Codes.
  295. * EBADMSG: (libc)Error Codes.
  296. * EBADR: (libc)Error Codes.
  297. * EBADRPC: (libc)Error Codes.
  298. * EBADRQC: (libc)Error Codes.
  299. * EBADSLT: (libc)Error Codes.
  300. * EBFONT: (libc)Error Codes.
  301. * EBUSY: (libc)Error Codes.
  302. * ECANCELED: (libc)Error Codes.
  303. * ecb_crypt: (libc)DES Encryption.
  304. * ECHILD: (libc)Error Codes.
  305. * ECHOCTL: (libc)Local Modes.
  306. * ECHOE: (libc)Local Modes.
  307. * ECHOKE: (libc)Local Modes.
  308. * ECHOK: (libc)Local Modes.
  309. * ECHO: (libc)Local Modes.
  310. * ECHONL: (libc)Local Modes.
  311. * ECHOPRT: (libc)Local Modes.
  312. * ECHRNG: (libc)Error Codes.
  313. * ECOMM: (libc)Error Codes.
  314. * ECONNABORTED: (libc)Error Codes.
  315. * ECONNREFUSED: (libc)Error Codes.
  316. * ECONNRESET: (libc)Error Codes.
  317. * ecvt: (libc)System V Number Conversion.
  318. * ecvt_r: (libc)System V Number Conversion.
  319. * EDEADLK: (libc)Error Codes.
  320. * EDEADLOCK: (libc)Error Codes.
  321. * EDESTADDRREQ: (libc)Error Codes.
  322. * EDIED: (libc)Error Codes.
  323. * ED: (libc)Error Codes.
  324. * EDOM: (libc)Error Codes.
  325. * EDOTDOT: (libc)Error Codes.
  326. * EDQUOT: (libc)Error Codes.
  327. * EEXIST: (libc)Error Codes.
  328. * EFAULT: (libc)Error Codes.
  329. * EFBIG: (libc)Error Codes.
  330. * EFTYPE: (libc)Error Codes.
  331. * EGRATUITOUS: (libc)Error Codes.
  332. * EGREGIOUS: (libc)Error Codes.
  333. * EHOSTDOWN: (libc)Error Codes.
  334. * EHOSTUNREACH: (libc)Error Codes.
  335. * EHWPOISON: (libc)Error Codes.
  336. * EIDRM: (libc)Error Codes.
  337. * EIEIO: (libc)Error Codes.
  338. * EILSEQ: (libc)Error Codes.
  339. * EINPROGRESS: (libc)Error Codes.
  340. * EINTR: (libc)Error Codes.
  341. * EINVAL: (libc)Error Codes.
  342. * EIO: (libc)Error Codes.
  343. * EISCONN: (libc)Error Codes.
  344. * EISDIR: (libc)Error Codes.
  345. * EISNAM: (libc)Error Codes.
  346. * EKEYEXPIRED: (libc)Error Codes.
  347. * EKEYREJECTED: (libc)Error Codes.
  348. * EKEYREVOKED: (libc)Error Codes.
  349. * EL2HLT: (libc)Error Codes.
  350. * EL2NSYNC: (libc)Error Codes.
  351. * EL3HLT: (libc)Error Codes.
  352. * EL3RST: (libc)Error Codes.
  353. * ELIBACC: (libc)Error Codes.
  354. * ELIBBAD: (libc)Error Codes.
  355. * ELIBEXEC: (libc)Error Codes.
  356. * ELIBMAX: (libc)Error Codes.
  357. * ELIBSCN: (libc)Error Codes.
  358. * ELNRNG: (libc)Error Codes.
  359. * ELOOP: (libc)Error Codes.
  360. * EMEDIUMTYPE: (libc)Error Codes.
  361. * EMFILE: (libc)Error Codes.
  362. * EMLINK: (libc)Error Codes.
  363. * EMSGSIZE: (libc)Error Codes.
  364. * EMULTIHOP: (libc)Error Codes.
  365. * ENAMETOOLONG: (libc)Error Codes.
  366. * ENAVAIL: (libc)Error Codes.
  367. * encrypt: (libc)DES Encryption.
  368. * encrypt_r: (libc)DES Encryption.
  369. * endfsent: (libc)fstab.
  370. * endgrent: (libc)Scanning All Groups.
  371. * endhostent: (libc)Host Names.
  372. * endmntent: (libc)mtab.
  373. * endnetent: (libc)Networks Database.
  374. * endnetgrent: (libc)Lookup Netgroup.
  375. * endprotoent: (libc)Protocols Database.
  376. * endpwent: (libc)Scanning All Users.
  377. * endservent: (libc)Services Database.
  378. * endutent: (libc)Manipulating the Database.
  379. * endutxent: (libc)XPG Functions.
  380. * ENEEDAUTH: (libc)Error Codes.
  381. * ENETDOWN: (libc)Error Codes.
  382. * ENETRESET: (libc)Error Codes.
  383. * ENETUNREACH: (libc)Error Codes.
  384. * ENFILE: (libc)Error Codes.
  385. * ENOANO: (libc)Error Codes.
  386. * ENOBUFS: (libc)Error Codes.
  387. * ENOCSI: (libc)Error Codes.
  388. * ENODATA: (libc)Error Codes.
  389. * ENODEV: (libc)Error Codes.
  390. * ENOENT: (libc)Error Codes.
  391. * ENOEXEC: (libc)Error Codes.
  392. * ENOKEY: (libc)Error Codes.
  393. * ENOLCK: (libc)Error Codes.
  394. * ENOLINK: (libc)Error Codes.
  395. * ENOMEDIUM: (libc)Error Codes.
  396. * ENOMEM: (libc)Error Codes.
  397. * ENOMSG: (libc)Error Codes.
  398. * ENONET: (libc)Error Codes.
  399. * ENOPKG: (libc)Error Codes.
  400. * ENOPROTOOPT: (libc)Error Codes.
  401. * ENOSPC: (libc)Error Codes.
  402. * ENOSR: (libc)Error Codes.
  403. * ENOSTR: (libc)Error Codes.
  404. * ENOSYS: (libc)Error Codes.
  405. * ENOTBLK: (libc)Error Codes.
  406. * ENOTCONN: (libc)Error Codes.
  407. * ENOTDIR: (libc)Error Codes.
  408. * ENOTEMPTY: (libc)Error Codes.
  409. * ENOTNAM: (libc)Error Codes.
  410. * ENOTRECOVERABLE: (libc)Error Codes.
  411. * ENOTSOCK: (libc)Error Codes.
  412. * ENOTSUP: (libc)Error Codes.
  413. * ENOTTY: (libc)Error Codes.
  414. * ENOTUNIQ: (libc)Error Codes.
  415. * envz_add: (libc)Envz Functions.
  416. * envz_entry: (libc)Envz Functions.
  417. * envz_get: (libc)Envz Functions.
  418. * envz_merge: (libc)Envz Functions.
  419. * envz_remove: (libc)Envz Functions.
  420. * envz_strip: (libc)Envz Functions.
  421. * ENXIO: (libc)Error Codes.
  422. * EOF: (libc)EOF and Errors.
  423. * EOPNOTSUPP: (libc)Error Codes.
  424. * EOVERFLOW: (libc)Error Codes.
  425. * EOWNERDEAD: (libc)Error Codes.
  426. * EPERM: (libc)Error Codes.
  427. * EPFNOSUPPORT: (libc)Error Codes.
  428. * EPIPE: (libc)Error Codes.
  429. * EPROCLIM: (libc)Error Codes.
  430. * EPROCUNAVAIL: (libc)Error Codes.
  431. * EPROGMISMATCH: (libc)Error Codes.
  432. * EPROGUNAVAIL: (libc)Error Codes.
  433. * EPROTO: (libc)Error Codes.
  434. * EPROTONOSUPPORT: (libc)Error Codes.
  435. * EPROTOTYPE: (libc)Error Codes.
  436. * EQUIV_CLASS_MAX: (libc)Utility Limits.
  437. * erand48: (libc)SVID Random.
  438. * erand48_r: (libc)SVID Random.
  439. * ERANGE: (libc)Error Codes.
  440. * EREMCHG: (libc)Error Codes.
  441. * EREMOTEIO: (libc)Error Codes.
  442. * EREMOTE: (libc)Error Codes.
  443. * ERESTART: (libc)Error Codes.
  444. * erfcf: (libc)Special Functions.
  445. * erfc: (libc)Special Functions.
  446. * erfcl: (libc)Special Functions.
  447. * erff: (libc)Special Functions.
  448. * ERFKILL: (libc)Error Codes.
  449. * erf: (libc)Special Functions.
  450. * erfl: (libc)Special Functions.
  451. * EROFS: (libc)Error Codes.
  452. * ERPCMISMATCH: (libc)Error Codes.
  453. * err: (libc)Error Messages.
  454. * errno: (libc)Checking for Errors.
  455. * error_at_line: (libc)Error Messages.
  456. * error: (libc)Error Messages.
  457. * errx: (libc)Error Messages.
  458. * ESHUTDOWN: (libc)Error Codes.
  459. * ESOCKTNOSUPPORT: (libc)Error Codes.
  460. * ESPIPE: (libc)Error Codes.
  461. * ESRCH: (libc)Error Codes.
  462. * ESRMNT: (libc)Error Codes.
  463. * ESTALE: (libc)Error Codes.
  464. * ESTRPIPE: (libc)Error Codes.
  465. * ETIMEDOUT: (libc)Error Codes.
  466. * ETIME: (libc)Error Codes.
  467. * ETOOMANYREFS: (libc)Error Codes.
  468. * ETXTBSY: (libc)Error Codes.
  469. * EUCLEAN: (libc)Error Codes.
  470. * EUNATCH: (libc)Error Codes.
  471. * EUSERS: (libc)Error Codes.
  472. * EWOULDBLOCK: (libc)Error Codes.
  473. * EXDEV: (libc)Error Codes.
  474. * execle: (libc)Executing a File.
  475. * execl: (libc)Executing a File.
  476. * execlp: (libc)Executing a File.
  477. * execve: (libc)Executing a File.
  478. * execv: (libc)Executing a File.
  479. * execvp: (libc)Executing a File.
  480. * EXFULL: (libc)Error Codes.
  481. * EXIT_FAILURE: (libc)Exit Status.
  482. * exit: (libc)Normal Termination.
  483. * _exit: (libc)Termination Internals.
  484. * _Exit: (libc)Termination Internals.
  485. * EXIT_SUCCESS: (libc)Exit Status.
  486. * exp10f: (libc)Exponents and Logarithms.
  487. * exp10: (libc)Exponents and Logarithms.
  488. * exp10l: (libc)Exponents and Logarithms.
  489. * exp2f: (libc)Exponents and Logarithms.
  490. * exp2: (libc)Exponents and Logarithms.
  491. * exp2l: (libc)Exponents and Logarithms.
  492. * expf: (libc)Exponents and Logarithms.
  493. * exp: (libc)Exponents and Logarithms.
  494. * explicit_bzero: (libc)Erasing Sensitive Data.
  495. * expl: (libc)Exponents and Logarithms.
  496. * expm1f: (libc)Exponents and Logarithms.
  497. * expm1: (libc)Exponents and Logarithms.
  498. * expm1l: (libc)Exponents and Logarithms.
  499. * EXPR_NEST_MAX: (libc)Utility Limits.
  500. * fabsf: (libc)Absolute Value.
  501. * fabs: (libc)Absolute Value.
  502. * fabsl: (libc)Absolute Value.
  503. * __fbufsize: (libc)Controlling Buffering.
  504. * fchdir: (libc)Working Directory.
  505. * fchmod: (libc)Setting Permissions.
  506. * fchown: (libc)File Owner.
  507. * fcloseall: (libc)Closing Streams.
  508. * fclose: (libc)Closing Streams.
  509. * fcntl: (libc)Control Operations.
  510. * fcvt: (libc)System V Number Conversion.
  511. * fcvt_r: (libc)System V Number Conversion.
  512. * fdatasync: (libc)Synchronizing I/O.
  513. * FD_CLOEXEC: (libc)Descriptor Flags.
  514. * FD_CLR: (libc)Waiting for I/O.
  515. * fdimf: (libc)Misc FP Arithmetic.
  516. * fdim: (libc)Misc FP Arithmetic.
  517. * fdiml: (libc)Misc FP Arithmetic.
  518. * FD_ISSET: (libc)Waiting for I/O.
  519. * fdopendir: (libc)Opening a Directory.
  520. * fdopen: (libc)Descriptors and Streams.
  521. * FD_SET: (libc)Waiting for I/O.
  522. * FD_SETSIZE: (libc)Waiting for I/O.
  523. * F_DUPFD: (libc)Duplicating Descriptors.
  524. * FD_ZERO: (libc)Waiting for I/O.
  525. * feclearexcept: (libc)Status bit operations.
  526. * fedisableexcept: (libc)Control Functions.
  527. * feenableexcept: (libc)Control Functions.
  528. * fegetenv: (libc)Control Functions.
  529. * fegetexceptflag: (libc)Status bit operations.
  530. * fegetexcept: (libc)Control Functions.
  531. * fegetmode: (libc)Control Functions.
  532. * fegetround: (libc)Rounding.
  533. * feholdexcept: (libc)Control Functions.
  534. * feof: (libc)EOF and Errors.
  535. * feof_unlocked: (libc)EOF and Errors.
  536. * feraiseexcept: (libc)Status bit operations.
  537. * ferror: (libc)EOF and Errors.
  538. * ferror_unlocked: (libc)EOF and Errors.
  539. * fesetenv: (libc)Control Functions.
  540. * fesetexceptflag: (libc)Status bit operations.
  541. * fesetexcept: (libc)Status bit operations.
  542. * fesetmode: (libc)Control Functions.
  543. * fesetround: (libc)Rounding.
  544. * FE_SNANS_ALWAYS_SIGNAL: (libc)Infinity and NaN.
  545. * fetestexceptflag: (libc)Status bit operations.
  546. * fetestexcept: (libc)Status bit operations.
  547. * feupdateenv: (libc)Control Functions.
  548. * fflush: (libc)Flushing Buffers.
  549. * fflush_unlocked: (libc)Flushing Buffers.
  550. * fgetc: (libc)Character Input.
  551. * fgetc_unlocked: (libc)Character Input.
  552. * F_GETFD: (libc)Descriptor Flags.
  553. * F_GETFL: (libc)Getting File Status Flags.
  554. * fgetgrent: (libc)Scanning All Groups.
  555. * fgetgrent_r: (libc)Scanning All Groups.
  556. * F_GETLK: (libc)File Locks.
  557. * F_GETOWN: (libc)Interrupt Input.
  558. * fgetpos64: (libc)Portable Positioning.
  559. * fgetpos: (libc)Portable Positioning.
  560. * fgetpwent: (libc)Scanning All Users.
  561. * fgetpwent_r: (libc)Scanning All Users.
  562. * fgets: (libc)Line Input.
  563. * fgets_unlocked: (libc)Line Input.
  564. * fgetwc: (libc)Character Input.
  565. * fgetwc_unlocked: (libc)Character Input.
  566. * fgetws: (libc)Line Input.
  567. * fgetws_unlocked: (libc)Line Input.
  568. * FILENAME_MAX: (libc)Limits for Files.
  569. * fileno: (libc)Descriptors and Streams.
  570. * fileno_unlocked: (libc)Descriptors and Streams.
  571. * finitef: (libc)Floating Point Classes.
  572. * finite: (libc)Floating Point Classes.
  573. * finitel: (libc)Floating Point Classes.
  574. * __flbf: (libc)Controlling Buffering.
  575. * flockfile: (libc)Streams and Threads.
  576. * floorf: (libc)Rounding Functions.
  577. * floor: (libc)Rounding Functions.
  578. * floorl: (libc)Rounding Functions.
  579. * _flushlbf: (libc)Flushing Buffers.
  580. * FLUSHO: (libc)Local Modes.
  581. * fmaf: (libc)Misc FP Arithmetic.
  582. * fma: (libc)Misc FP Arithmetic.
  583. * fmal: (libc)Misc FP Arithmetic.
  584. * fmaxf: (libc)Misc FP Arithmetic.
  585. * fmax: (libc)Misc FP Arithmetic.
  586. * fmaxl: (libc)Misc FP Arithmetic.
  587. * fmaxmagf: (libc)Misc FP Arithmetic.
  588. * fmaxmag: (libc)Misc FP Arithmetic.
  589. * fmaxmagl: (libc)Misc FP Arithmetic.
  590. * fmemopen: (libc)String Streams.
  591. * fminf: (libc)Misc FP Arithmetic.
  592. * fmin: (libc)Misc FP Arithmetic.
  593. * fminl: (libc)Misc FP Arithmetic.
  594. * fminmagf: (libc)Misc FP Arithmetic.
  595. * fminmag: (libc)Misc FP Arithmetic.
  596. * fminmagl: (libc)Misc FP Arithmetic.
  597. * fmodf: (libc)Remainder Functions.
  598. * fmod: (libc)Remainder Functions.
  599. * fmodl: (libc)Remainder Functions.
  600. * fmtmsg: (libc)Printing Formatted Messages.
  601. * fnmatch: (libc)Wildcard Matching.
  602. * F_OFD_GETLK: (libc)Open File Description Locks.
  603. * F_OFD_SETLK: (libc)Open File Description Locks.
  604. * F_OFD_SETLKW: (libc)Open File Description Locks.
  605. * F_OK: (libc)Testing File Access.
  606. * fopen64: (libc)Opening Streams.
  607. * fopencookie: (libc)Streams and Cookies.
  608. * fopen: (libc)Opening Streams.
  609. * FOPEN_MAX: (libc)Opening Streams.
  610. * fork: (libc)Creating a Process.
  611. * forkpty: (libc)Pseudo-Terminal Pairs.
  612. * fpathconf: (libc)Pathconf.
  613. * fpclassify: (libc)Floating Point Classes.
  614. * __fpending: (libc)Controlling Buffering.
  615. * FP_ILOGB0: (libc)Exponents and Logarithms.
  616. * FP_ILOGBNAN: (libc)Exponents and Logarithms.
  617. * FP_LLOGB0: (libc)Exponents and Logarithms.
  618. * FP_LLOGBNAN: (libc)Exponents and Logarithms.
  619. * fprintf: (libc)Formatted Output Functions.
  620. * __fpurge: (libc)Flushing Buffers.
  621. * fputc: (libc)Simple Output.
  622. * fputc_unlocked: (libc)Simple Output.
  623. * fputs: (libc)Simple Output.
  624. * fputs_unlocked: (libc)Simple Output.
  625. * fputwc: (libc)Simple Output.
  626. * fputwc_unlocked: (libc)Simple Output.
  627. * fputws: (libc)Simple Output.
  628. * fputws_unlocked: (libc)Simple Output.
  629. * __freadable: (libc)Opening Streams.
  630. * __freading: (libc)Opening Streams.
  631. * fread: (libc)Block Input/Output.
  632. * fread_unlocked: (libc)Block Input/Output.
  633. * free: (libc)Freeing after Malloc.
  634. * freopen64: (libc)Opening Streams.
  635. * freopen: (libc)Opening Streams.
  636. * frexpf: (libc)Normalization Functions.
  637. * frexp: (libc)Normalization Functions.
  638. * frexpl: (libc)Normalization Functions.
  639. * fromfpf: (libc)Rounding Functions.
  640. * fromfp: (libc)Rounding Functions.
  641. * fromfpl: (libc)Rounding Functions.
  642. * fromfpxf: (libc)Rounding Functions.
  643. * fromfpx: (libc)Rounding Functions.
  644. * fromfpxl: (libc)Rounding Functions.
  645. * fscanf: (libc)Formatted Input Functions.
  646. * fseek: (libc)File Positioning.
  647. * fseeko64: (libc)File Positioning.
  648. * fseeko: (libc)File Positioning.
  649. * F_SETFD: (libc)Descriptor Flags.
  650. * F_SETFL: (libc)Getting File Status Flags.
  651. * F_SETLK: (libc)File Locks.
  652. * F_SETLKW: (libc)File Locks.
  653. * __fsetlocking: (libc)Streams and Threads.
  654. * F_SETOWN: (libc)Interrupt Input.
  655. * fsetpos64: (libc)Portable Positioning.
  656. * fsetpos: (libc)Portable Positioning.
  657. * fstat64: (libc)Reading Attributes.
  658. * fstat: (libc)Reading Attributes.
  659. * fsync: (libc)Synchronizing I/O.
  660. * ftell: (libc)File Positioning.
  661. * ftello64: (libc)File Positioning.
  662. * ftello: (libc)File Positioning.
  663. * ftruncate64: (libc)File Size.
  664. * ftruncate: (libc)File Size.
  665. * ftrylockfile: (libc)Streams and Threads.
  666. * ftw64: (libc)Working with Directory Trees.
  667. * ftw: (libc)Working with Directory Trees.
  668. * funlockfile: (libc)Streams and Threads.
  669. * futimes: (libc)File Times.
  670. * fwide: (libc)Streams and I18N.
  671. * fwprintf: (libc)Formatted Output Functions.
  672. * __fwritable: (libc)Opening Streams.
  673. * fwrite: (libc)Block Input/Output.
  674. * fwrite_unlocked: (libc)Block Input/Output.
  675. * __fwriting: (libc)Opening Streams.
  676. * fwscanf: (libc)Formatted Input Functions.
  677. * gammaf: (libc)Special Functions.
  678. * gamma: (libc)Special Functions.
  679. * gammal: (libc)Special Functions.
  680. * __gconv_end_fct: (libc)glibc iconv Implementation.
  681. * __gconv_fct: (libc)glibc iconv Implementation.
  682. * __gconv_init_fct: (libc)glibc iconv Implementation.
  683. * gcvt: (libc)System V Number Conversion.
  684. * getauxval: (libc)Auxiliary Vector.
  685. * get_avphys_pages: (libc)Query Memory Parameters.
  686. * getchar: (libc)Character Input.
  687. * getchar_unlocked: (libc)Character Input.
  688. * getc: (libc)Character Input.
  689. * getcontext: (libc)System V contexts.
  690. * getc_unlocked: (libc)Character Input.
  691. * get_current_dir_name: (libc)Working Directory.
  692. * getcwd: (libc)Working Directory.
  693. * getdate: (libc)General Time String Parsing.
  694. * getdate_r: (libc)General Time String Parsing.
  695. * getdelim: (libc)Line Input.
  696. * getdomainnname: (libc)Host Identification.
  697. * getegid: (libc)Reading Persona.
  698. * getentropy: (libc)Unpredictable Bytes.
  699. * getenv: (libc)Environment Access.
  700. * geteuid: (libc)Reading Persona.
  701. * getfsent: (libc)fstab.
  702. * getfsfile: (libc)fstab.
  703. * getfsspec: (libc)fstab.
  704. * getgid: (libc)Reading Persona.
  705. * getgrent: (libc)Scanning All Groups.
  706. * getgrent_r: (libc)Scanning All Groups.
  707. * getgrgid: (libc)Lookup Group.
  708. * getgrgid_r: (libc)Lookup Group.
  709. * getgrnam: (libc)Lookup Group.
  710. * getgrnam_r: (libc)Lookup Group.
  711. * getgrouplist: (libc)Setting Groups.
  712. * getgroups: (libc)Reading Persona.
  713. * gethostbyaddr: (libc)Host Names.
  714. * gethostbyaddr_r: (libc)Host Names.
  715. * gethostbyname2: (libc)Host Names.
  716. * gethostbyname2_r: (libc)Host Names.
  717. * gethostbyname: (libc)Host Names.
  718. * gethostbyname_r: (libc)Host Names.
  719. * gethostent: (libc)Host Names.
  720. * gethostid: (libc)Host Identification.
  721. * gethostname: (libc)Host Identification.
  722. * getitimer: (libc)Setting an Alarm.
  723. * getline: (libc)Line Input.
  724. * getloadavg: (libc)Processor Resources.
  725. * getlogin: (libc)Who Logged In.
  726. * getmntent: (libc)mtab.
  727. * getmntent_r: (libc)mtab.
  728. * getnetbyaddr: (libc)Networks Database.
  729. * getnetbyname: (libc)Networks Database.
  730. * getnetent: (libc)Networks Database.
  731. * getnetgrent: (libc)Lookup Netgroup.
  732. * getnetgrent_r: (libc)Lookup Netgroup.
  733. * get_nprocs_conf: (libc)Processor Resources.
  734. * get_nprocs: (libc)Processor Resources.
  735. * getopt: (libc)Using Getopt.
  736. * getopt_long: (libc)Getopt Long Options.
  737. * getopt_long_only: (libc)Getopt Long Options.
  738. * getpagesize: (libc)Query Memory Parameters.
  739. * getpass: (libc)getpass.
  740. * getpayloadf: (libc)FP Bit Twiddling.
  741. * getpayload: (libc)FP Bit Twiddling.
  742. * getpayloadl: (libc)FP Bit Twiddling.
  743. * getpeername: (libc)Who is Connected.
  744. * getpgid: (libc)Process Group Functions.
  745. * getpgrp: (libc)Process Group Functions.
  746. * get_phys_pages: (libc)Query Memory Parameters.
  747. * getpid: (libc)Process Identification.
  748. * getppid: (libc)Process Identification.
  749. * getpriority: (libc)Traditional Scheduling Functions.
  750. * getprotobyname: (libc)Protocols Database.
  751. * getprotobynumber: (libc)Protocols Database.
  752. * getprotoent: (libc)Protocols Database.
  753. * getpt: (libc)Allocation.
  754. * getpwent: (libc)Scanning All Users.
  755. * getpwent_r: (libc)Scanning All Users.
  756. * getpwnam: (libc)Lookup User.
  757. * getpwnam_r: (libc)Lookup User.
  758. * getpwuid: (libc)Lookup User.
  759. * getpwuid_r: (libc)Lookup User.
  760. * getrandom: (libc)Unpredictable Bytes.
  761. * getrlimit64: (libc)Limits on Resources.
  762. * getrlimit: (libc)Limits on Resources.
  763. * getrusage: (libc)Resource Usage.
  764. * getservbyname: (libc)Services Database.
  765. * getservbyport: (libc)Services Database.
  766. * getservent: (libc)Services Database.
  767. * getsid: (libc)Process Group Functions.
  768. * gets: (libc)Line Input.
  769. * getsockname: (libc)Reading Address.
  770. * getsockopt: (libc)Socket Option Functions.
  771. * getsubopt: (libc)Suboptions.
  772. * gettext: (libc)Translation with gettext.
  773. * gettimeofday: (libc)High-Resolution Calendar.
  774. * getuid: (libc)Reading Persona.
  775. * getumask: (libc)Setting Permissions.
  776. * getutent: (libc)Manipulating the Database.
  777. * getutent_r: (libc)Manipulating the Database.
  778. * getutid: (libc)Manipulating the Database.
  779. * getutid_r: (libc)Manipulating the Database.
  780. * getutline: (libc)Manipulating the Database.
  781. * getutline_r: (libc)Manipulating the Database.
  782. * getutmp: (libc)XPG Functions.
  783. * getutmpx: (libc)XPG Functions.
  784. * getutxent: (libc)XPG Functions.
  785. * getutxid: (libc)XPG Functions.
  786. * getutxline: (libc)XPG Functions.
  787. * getwchar: (libc)Character Input.
  788. * getwchar_unlocked: (libc)Character Input.
  789. * getwc: (libc)Character Input.
  790. * getwc_unlocked: (libc)Character Input.
  791. * getwd: (libc)Working Directory.
  792. * getw: (libc)Character Input.
  793. * glob64: (libc)Calling Glob.
  794. * globfree64: (libc)More Flags for Globbing.
  795. * globfree: (libc)More Flags for Globbing.
  796. * glob: (libc)Calling Glob.
  797. * gmtime: (libc)Broken-down Time.
  798. * gmtime_r: (libc)Broken-down Time.
  799. * grantpt: (libc)Allocation.
  800. * gsignal: (libc)Signaling Yourself.
  801. * gtty: (libc)BSD Terminal Modes.
  802. * hasmntopt: (libc)mtab.
  803. * hcreate: (libc)Hash Search Function.
  804. * hcreate_r: (libc)Hash Search Function.
  805. * hdestroy: (libc)Hash Search Function.
  806. * hdestroy_r: (libc)Hash Search Function.
  807. * hsearch: (libc)Hash Search Function.
  808. * hsearch_r: (libc)Hash Search Function.
  809. * htonl: (libc)Byte Order.
  810. * htons: (libc)Byte Order.
  811. * HUGE_VALF: (libc)Math Error Reporting.
  812. * HUGE_VAL: (libc)Math Error Reporting.
  813. * HUGE_VALL: (libc)Math Error Reporting.
  814. * HUPCL: (libc)Control Modes.
  815. * hypotf: (libc)Exponents and Logarithms.
  816. * hypot: (libc)Exponents and Logarithms.
  817. * hypotl: (libc)Exponents and Logarithms.
  818. * ICANON: (libc)Local Modes.
  819. * iconv_close: (libc)Generic Conversion Interface.
  820. * iconv: (libc)Generic Conversion Interface.
  821. * iconv_open: (libc)Generic Conversion Interface.
  822. * ICRNL: (libc)Input Modes.
  823. * IEXTEN: (libc)Local Modes.
  824. * if_freenameindex: (libc)Interface Naming.
  825. * if_indextoname: (libc)Interface Naming.
  826. * if_nameindex: (libc)Interface Naming.
  827. * if_nametoindex: (libc)Interface Naming.
  828. * IFNAMSIZ: (libc)Interface Naming.
  829. * IFTODT: (libc)Directory Entries.
  830. * IGNBRK: (libc)Input Modes.
  831. * IGNCR: (libc)Input Modes.
  832. * IGNPAR: (libc)Input Modes.
  833. * I: (libc)Complex Numbers.
  834. * ilogbf: (libc)Exponents and Logarithms.
  835. * ilogb: (libc)Exponents and Logarithms.
  836. * ilogbl: (libc)Exponents and Logarithms.
  837. * _Imaginary_I: (libc)Complex Numbers.
  838. * imaxabs: (libc)Absolute Value.
  839. * IMAXBEL: (libc)Input Modes.
  840. * imaxdiv: (libc)Integer Division.
  841. * in6addr_any: (libc)Host Address Data Type.
  842. * in6addr_loopback: (libc)Host Address Data Type.
  843. * INADDR_ANY: (libc)Host Address Data Type.
  844. * INADDR_BROADCAST: (libc)Host Address Data Type.
  845. * INADDR_LOOPBACK: (libc)Host Address Data Type.
  846. * INADDR_NONE: (libc)Host Address Data Type.
  847. * index: (libc)Search Functions.
  848. * inet_addr: (libc)Host Address Functions.
  849. * inet_aton: (libc)Host Address Functions.
  850. * inet_lnaof: (libc)Host Address Functions.
  851. * inet_makeaddr: (libc)Host Address Functions.
  852. * inet_netof: (libc)Host Address Functions.
  853. * inet_network: (libc)Host Address Functions.
  854. * inet_ntoa: (libc)Host Address Functions.
  855. * inet_ntop: (libc)Host Address Functions.
  856. * inet_pton: (libc)Host Address Functions.
  857. * INFINITY: (libc)Infinity and NaN.
  858. * initgroups: (libc)Setting Groups.
  859. * initstate: (libc)BSD Random.
  860. * initstate_r: (libc)BSD Random.
  861. * INLCR: (libc)Input Modes.
  862. * innetgr: (libc)Netgroup Membership.
  863. * INPCK: (libc)Input Modes.
  864. * ioctl: (libc)IOCTLs.
  865. * _IOFBF: (libc)Controlling Buffering.
  866. * _IOLBF: (libc)Controlling Buffering.
  867. * _IONBF: (libc)Controlling Buffering.
  868. * IPPORT_RESERVED: (libc)Ports.
  869. * IPPORT_USERRESERVED: (libc)Ports.
  870. * isalnum: (libc)Classification of Characters.
  871. * isalpha: (libc)Classification of Characters.
  872. * isascii: (libc)Classification of Characters.
  873. * isatty: (libc)Is It a Terminal.
  874. * isblank: (libc)Classification of Characters.
  875. * iscanonical: (libc)Floating Point Classes.
  876. * iscntrl: (libc)Classification of Characters.
  877. * isdigit: (libc)Classification of Characters.
  878. * iseqsig: (libc)FP Comparison Functions.
  879. * isfinite: (libc)Floating Point Classes.
  880. * isgraph: (libc)Classification of Characters.
  881. * isgreaterequal: (libc)FP Comparison Functions.
  882. * isgreater: (libc)FP Comparison Functions.
  883. * ISIG: (libc)Local Modes.
  884. * isinff: (libc)Floating Point Classes.
  885. * isinf: (libc)Floating Point Classes.
  886. * isinfl: (libc)Floating Point Classes.
  887. * islessequal: (libc)FP Comparison Functions.
  888. * islessgreater: (libc)FP Comparison Functions.
  889. * isless: (libc)FP Comparison Functions.
  890. * islower: (libc)Classification of Characters.
  891. * isnanf: (libc)Floating Point Classes.
  892. * isnan: (libc)Floating Point Classes.
  893. * isnan: (libc)Floating Point Classes.
  894. * isnanl: (libc)Floating Point Classes.
  895. * isnormal: (libc)Floating Point Classes.
  896. * isprint: (libc)Classification of Characters.
  897. * ispunct: (libc)Classification of Characters.
  898. * issignaling: (libc)Floating Point Classes.
  899. * isspace: (libc)Classification of Characters.
  900. * issubnormal: (libc)Floating Point Classes.
  901. * ISTRIP: (libc)Input Modes.
  902. * isunordered: (libc)FP Comparison Functions.
  903. * isupper: (libc)Classification of Characters.
  904. * iswalnum: (libc)Classification of Wide Characters.
  905. * iswalpha: (libc)Classification of Wide Characters.
  906. * iswblank: (libc)Classification of Wide Characters.
  907. * iswcntrl: (libc)Classification of Wide Characters.
  908. * iswctype: (libc)Classification of Wide Characters.
  909. * iswdigit: (libc)Classification of Wide Characters.
  910. * iswgraph: (libc)Classification of Wide Characters.
  911. * iswlower: (libc)Classification of Wide Characters.
  912. * iswprint: (libc)Classification of Wide Characters.
  913. * iswpunct: (libc)Classification of Wide Characters.
  914. * iswspace: (libc)Classification of Wide Characters.
  915. * iswupper: (libc)Classification of Wide Characters.
  916. * iswxdigit: (libc)Classification of Wide Characters.
  917. * isxdigit: (libc)Classification of Characters.
  918. * iszero: (libc)Floating Point Classes.
  919. * IXANY: (libc)Input Modes.
  920. * IXOFF: (libc)Input Modes.
  921. * IXON: (libc)Input Modes.
  922. * j0f: (libc)Special Functions.
  923. * j0: (libc)Special Functions.
  924. * j0l: (libc)Special Functions.
  925. * j1f: (libc)Special Functions.
  926. * j1: (libc)Special Functions.
  927. * j1l: (libc)Special Functions.
  928. * jnf: (libc)Special Functions.
  929. * jn: (libc)Special Functions.
  930. * jnl: (libc)Special Functions.
  931. * jrand48: (libc)SVID Random.
  932. * jrand48_r: (libc)SVID Random.
  933. * kill: (libc)Signaling Another Process.
  934. * killpg: (libc)Signaling Another Process.
  935. * l64a: (libc)Encode Binary Data.
  936. * labs: (libc)Absolute Value.
  937. * lcong48: (libc)SVID Random.
  938. * lcong48_r: (libc)SVID Random.
  939. * L_ctermid: (libc)Identifying the Terminal.
  940. * L_cuserid: (libc)Who Logged In.
  941. * ldexpf: (libc)Normalization Functions.
  942. * ldexp: (libc)Normalization Functions.
  943. * ldexpl: (libc)Normalization Functions.
  944. * ldiv: (libc)Integer Division.
  945. * lfind: (libc)Array Search Function.
  946. * lgammaf: (libc)Special Functions.
  947. * lgammaf_r: (libc)Special Functions.
  948. * lgamma: (libc)Special Functions.
  949. * lgammal: (libc)Special Functions.
  950. * lgammal_r: (libc)Special Functions.
  951. * lgamma_r: (libc)Special Functions.
  952. * LINE_MAX: (libc)Utility Limits.
  953. * link: (libc)Hard Links.
  954. * LINK_MAX: (libc)Limits for Files.
  955. * lio_listio64: (libc)Asynchronous Reads/Writes.
  956. * lio_listio: (libc)Asynchronous Reads/Writes.
  957. * listen: (libc)Listening.
  958. * llabs: (libc)Absolute Value.
  959. * lldiv: (libc)Integer Division.
  960. * llogbf: (libc)Exponents and Logarithms.
  961. * llogb: (libc)Exponents and Logarithms.
  962. * llogbl: (libc)Exponents and Logarithms.
  963. * llrintf: (libc)Rounding Functions.
  964. * llrint: (libc)Rounding Functions.
  965. * llrintl: (libc)Rounding Functions.
  966. * llroundf: (libc)Rounding Functions.
  967. * llround: (libc)Rounding Functions.
  968. * llroundl: (libc)Rounding Functions.
  969. * localeconv: (libc)The Lame Way to Locale Data.
  970. * localtime: (libc)Broken-down Time.
  971. * localtime_r: (libc)Broken-down Time.
  972. * log10f: (libc)Exponents and Logarithms.
  973. * log10: (libc)Exponents and Logarithms.
  974. * log10l: (libc)Exponents and Logarithms.
  975. * log1pf: (libc)Exponents and Logarithms.
  976. * log1p: (libc)Exponents and Logarithms.
  977. * log1pl: (libc)Exponents and Logarithms.
  978. * log2f: (libc)Exponents and Logarithms.
  979. * log2: (libc)Exponents and Logarithms.
  980. * log2l: (libc)Exponents and Logarithms.
  981. * logbf: (libc)Exponents and Logarithms.
  982. * logb: (libc)Exponents and Logarithms.
  983. * logbl: (libc)Exponents and Logarithms.
  984. * logf: (libc)Exponents and Logarithms.
  985. * login: (libc)Logging In and Out.
  986. * login_tty: (libc)Logging In and Out.
  987. * log: (libc)Exponents and Logarithms.
  988. * logl: (libc)Exponents and Logarithms.
  989. * logout: (libc)Logging In and Out.
  990. * logwtmp: (libc)Logging In and Out.
  991. * longjmp: (libc)Non-Local Details.
  992. * lrand48: (libc)SVID Random.
  993. * lrand48_r: (libc)SVID Random.
  994. * lrintf: (libc)Rounding Functions.
  995. * lrint: (libc)Rounding Functions.
  996. * lrintl: (libc)Rounding Functions.
  997. * lroundf: (libc)Rounding Functions.
  998. * lround: (libc)Rounding Functions.
  999. * lroundl: (libc)Rounding Functions.
  1000. * lsearch: (libc)Array Search Function.
  1001. * lseek64: (libc)File Position Primitive.
  1002. * lseek: (libc)File Position Primitive.
  1003. * lstat64: (libc)Reading Attributes.
  1004. * lstat: (libc)Reading Attributes.
  1005. * L_tmpnam: (libc)Temporary Files.
  1006. * lutimes: (libc)File Times.
  1007. * madvise: (libc)Memory-mapped I/O.
  1008. * makecontext: (libc)System V contexts.
  1009. * mallinfo: (libc)Statistics of Malloc.
  1010. * malloc: (libc)Basic Allocation.
  1011. * mallopt: (libc)Malloc Tunable Parameters.
  1012. * MAX_CANON: (libc)Limits for Files.
  1013. * MAX_INPUT: (libc)Limits for Files.
  1014. * MAXNAMLEN: (libc)Limits for Files.
  1015. * MAXSYMLINKS: (libc)Symbolic Links.
  1016. * MB_CUR_MAX: (libc)Selecting the Conversion.
  1017. * mblen: (libc)Non-reentrant Character Conversion.
  1018. * MB_LEN_MAX: (libc)Selecting the Conversion.
  1019. * mbrlen: (libc)Converting a Character.
  1020. * mbrtowc: (libc)Converting a Character.
  1021. * mbsinit: (libc)Keeping the state.
  1022. * mbsnrtowcs: (libc)Converting Strings.
  1023. * mbsrtowcs: (libc)Converting Strings.
  1024. * mbstowcs: (libc)Non-reentrant String Conversion.
  1025. * mbtowc: (libc)Non-reentrant Character Conversion.
  1026. * mcheck: (libc)Heap Consistency Checking.
  1027. * MDMBUF: (libc)Control Modes.
  1028. * memalign: (libc)Aligned Memory Blocks.
  1029. * memccpy: (libc)Copying Strings and Arrays.
  1030. * memchr: (libc)Search Functions.
  1031. * memcmp: (libc)String/Array Comparison.
  1032. * memcpy: (libc)Copying Strings and Arrays.
  1033. * memfrob: (libc)Trivial Encryption.
  1034. * memmem: (libc)Search Functions.
  1035. * memmove: (libc)Copying Strings and Arrays.
  1036. * mempcpy: (libc)Copying Strings and Arrays.
  1037. * memrchr: (libc)Search Functions.
  1038. * memset: (libc)Copying Strings and Arrays.
  1039. * mkdir: (libc)Creating Directories.
  1040. * mkdtemp: (libc)Temporary Files.
  1041. * mkfifo: (libc)FIFO Special Files.
  1042. * mknod: (libc)Making Special Files.
  1043. * mkstemp: (libc)Temporary Files.
  1044. * mktemp: (libc)Temporary Files.
  1045. * mktime: (libc)Broken-down Time.
  1046. * mlockall: (libc)Page Lock Functions.
  1047. * mlock: (libc)Page Lock Functions.
  1048. * mmap64: (libc)Memory-mapped I/O.
  1049. * mmap: (libc)Memory-mapped I/O.
  1050. * modff: (libc)Rounding Functions.
  1051. * modf: (libc)Rounding Functions.
  1052. * modfl: (libc)Rounding Functions.
  1053. * mount: (libc)Mount-Unmount-Remount.
  1054. * mprobe: (libc)Heap Consistency Checking.
  1055. * mrand48: (libc)SVID Random.
  1056. * mrand48_r: (libc)SVID Random.
  1057. * mremap: (libc)Memory-mapped I/O.
  1058. * MSG_DONTROUTE: (libc)Socket Data Options.
  1059. * MSG_OOB: (libc)Socket Data Options.
  1060. * MSG_PEEK: (libc)Socket Data Options.
  1061. * msync: (libc)Memory-mapped I/O.
  1062. * mtrace: (libc)Tracing malloc.
  1063. * munlockall: (libc)Page Lock Functions.
  1064. * munlock: (libc)Page Lock Functions.
  1065. * munmap: (libc)Memory-mapped I/O.
  1066. * muntrace: (libc)Tracing malloc.
  1067. * NAME_MAX: (libc)Limits for Files.
  1068. * nanf: (libc)FP Bit Twiddling.
  1069. * nan: (libc)FP Bit Twiddling.
  1070. * NAN: (libc)Infinity and NaN.
  1071. * nanl: (libc)FP Bit Twiddling.
  1072. * nanosleep: (libc)Sleeping.
  1073. * NCCS: (libc)Mode Data Types.
  1074. * nearbyintf: (libc)Rounding Functions.
  1075. * nearbyint: (libc)Rounding Functions.
  1076. * nearbyintl: (libc)Rounding Functions.
  1077. * nextafterf: (libc)FP Bit Twiddling.
  1078. * nextafter: (libc)FP Bit Twiddling.
  1079. * nextafterl: (libc)FP Bit Twiddling.
  1080. * nextdownf: (libc)FP Bit Twiddling.
  1081. * nextdown: (libc)FP Bit Twiddling.
  1082. * nextdownl: (libc)FP Bit Twiddling.
  1083. * nexttowardf: (libc)FP Bit Twiddling.
  1084. * nexttoward: (libc)FP Bit Twiddling.
  1085. * nexttowardl: (libc)FP Bit Twiddling.
  1086. * nextupf: (libc)FP Bit Twiddling.
  1087. * nextup: (libc)FP Bit Twiddling.
  1088. * nextupl: (libc)FP Bit Twiddling.
  1089. * nftw64: (libc)Working with Directory Trees.
  1090. * nftw: (libc)Working with Directory Trees.
  1091. * ngettext: (libc)Advanced gettext functions.
  1092. * NGROUPS_MAX: (libc)General Limits.
  1093. * nice: (libc)Traditional Scheduling Functions.
  1094. * nl_langinfo: (libc)The Elegant and Fast Way.
  1095. * NOFLSH: (libc)Local Modes.
  1096. * NOKERNINFO: (libc)Local Modes.
  1097. * nrand48: (libc)SVID Random.
  1098. * nrand48_r: (libc)SVID Random.
  1099. * NSIG: (libc)Standard Signals.
  1100. * ntohl: (libc)Byte Order.
  1101. * ntohs: (libc)Byte Order.
  1102. * ntp_adjtime: (libc)High Accuracy Clock.
  1103. * ntp_gettime: (libc)High Accuracy Clock.
  1104. * NULL: (libc)Null Pointer Constant.
  1105. * O_ACCMODE: (libc)Access Modes.
  1106. * O_APPEND: (libc)Operating Modes.
  1107. * O_ASYNC: (libc)Operating Modes.
  1108. * obstack_1grow_fast: (libc)Extra Fast Growing.
  1109. * obstack_1grow: (libc)Growing Objects.
  1110. * obstack_alignment_mask: (libc)Obstacks Data Alignment.
  1111. * obstack_alloc: (libc)Allocation in an Obstack.
  1112. * obstack_base: (libc)Status of an Obstack.
  1113. * obstack_blank_fast: (libc)Extra Fast Growing.
  1114. * obstack_blank: (libc)Growing Objects.
  1115. * obstack_chunk_size: (libc)Obstack Chunks.
  1116. * obstack_copy0: (libc)Allocation in an Obstack.
  1117. * obstack_copy: (libc)Allocation in an Obstack.
  1118. * obstack_finish: (libc)Growing Objects.
  1119. * obstack_free: (libc)Freeing Obstack Objects.
  1120. * obstack_grow0: (libc)Growing Objects.
  1121. * obstack_grow: (libc)Growing Objects.
  1122. * obstack_init: (libc)Preparing for Obstacks.
  1123. * obstack_int_grow_fast: (libc)Extra Fast Growing.
  1124. * obstack_int_grow: (libc)Growing Objects.
  1125. * obstack_next_free: (libc)Status of an Obstack.
  1126. * obstack_object_size: (libc)Growing Objects.
  1127. * obstack_object_size: (libc)Status of an Obstack.
  1128. * obstack_printf: (libc)Dynamic Output.
  1129. * obstack_ptr_grow_fast: (libc)Extra Fast Growing.
  1130. * obstack_ptr_grow: (libc)Growing Objects.
  1131. * obstack_room: (libc)Extra Fast Growing.
  1132. * obstack_vprintf: (libc)Variable Arguments Output.
  1133. * O_CREAT: (libc)Open-time Flags.
  1134. * O_EXCL: (libc)Open-time Flags.
  1135. * O_EXEC: (libc)Access Modes.
  1136. * O_EXLOCK: (libc)Open-time Flags.
  1137. * offsetof: (libc)Structure Measurement.
  1138. * O_FSYNC: (libc)Operating Modes.
  1139. * O_IGNORE_CTTY: (libc)Open-time Flags.
  1140. * O_NDELAY: (libc)Operating Modes.
  1141. * on_exit: (libc)Cleanups on Exit.
  1142. * ONLCR: (libc)Output Modes.
  1143. * O_NOATIME: (libc)Operating Modes.
  1144. * O_NOCTTY: (libc)Open-time Flags.
  1145. * ONOEOT: (libc)Output Modes.
  1146. * O_NOLINK: (libc)Open-time Flags.
  1147. * O_NONBLOCK: (libc)Open-time Flags.
  1148. * O_NONBLOCK: (libc)Operating Modes.
  1149. * O_NOTRANS: (libc)Open-time Flags.
  1150. * open64: (libc)Opening and Closing Files.
  1151. * opendir: (libc)Opening a Directory.
  1152. * open: (libc)Opening and Closing Files.
  1153. * openlog: (libc)openlog.
  1154. * OPEN_MAX: (libc)General Limits.
  1155. * open_memstream: (libc)String Streams.
  1156. * openpty: (libc)Pseudo-Terminal Pairs.
  1157. * OPOST: (libc)Output Modes.
  1158. * O_RDONLY: (libc)Access Modes.
  1159. * O_RDWR: (libc)Access Modes.
  1160. * O_READ: (libc)Access Modes.
  1161. * O_SHLOCK: (libc)Open-time Flags.
  1162. * O_SYNC: (libc)Operating Modes.
  1163. * O_TRUNC: (libc)Open-time Flags.
  1164. * O_WRITE: (libc)Access Modes.
  1165. * O_WRONLY: (libc)Access Modes.
  1166. * OXTABS: (libc)Output Modes.
  1167. * PA_FLAG_MASK: (libc)Parsing a Template String.
  1168. * PARENB: (libc)Control Modes.
  1169. * PARMRK: (libc)Input Modes.
  1170. * PARODD: (libc)Control Modes.
  1171. * parse_printf_format: (libc)Parsing a Template String.
  1172. * pathconf: (libc)Pathconf.
  1173. * PATH_MAX: (libc)Limits for Files.
  1174. * _PATH_UTMP: (libc)Manipulating the Database.
  1175. * _PATH_WTMP: (libc)Manipulating the Database.
  1176. * pause: (libc)Using Pause.
  1177. * pclose: (libc)Pipe to a Subprocess.
  1178. * PENDIN: (libc)Local Modes.
  1179. * perror: (libc)Error Messages.
  1180. * PF_FILE: (libc)Local Namespace Details.
  1181. * PF_INET6: (libc)Internet Namespace.
  1182. * PF_INET: (libc)Internet Namespace.
  1183. * PF_LOCAL: (libc)Local Namespace Details.
  1184. * PF_UNIX: (libc)Local Namespace Details.
  1185. * PIPE_BUF: (libc)Limits for Files.
  1186. * pipe: (libc)Creating a Pipe.
  1187. * popen: (libc)Pipe to a Subprocess.
  1188. * _POSIX2_C_DEV: (libc)System Options.
  1189. * _POSIX2_C_VERSION: (libc)Version Supported.
  1190. * _POSIX2_FORT_DEV: (libc)System Options.
  1191. * _POSIX2_FORT_RUN: (libc)System Options.
  1192. * _POSIX2_LOCALEDEF: (libc)System Options.
  1193. * _POSIX2_SW_DEV: (libc)System Options.
  1194. * _POSIX_CHOWN_RESTRICTED: (libc)Options for Files.
  1195. * posix_fallocate64: (libc)Storage Allocation.
  1196. * posix_fallocate: (libc)Storage Allocation.
  1197. * _POSIX_JOB_CONTROL: (libc)System Options.
  1198. * posix_memalign: (libc)Aligned Memory Blocks.
  1199. * _POSIX_NO_TRUNC: (libc)Options for Files.
  1200. * _POSIX_SAVED_IDS: (libc)System Options.
  1201. * _POSIX_VDISABLE: (libc)Options for Files.
  1202. * _POSIX_VERSION: (libc)Version Supported.
  1203. * pow10f: (libc)Exponents and Logarithms.
  1204. * pow10: (libc)Exponents and Logarithms.
  1205. * pow10l: (libc)Exponents and Logarithms.
  1206. * powf: (libc)Exponents and Logarithms.
  1207. * pow: (libc)Exponents and Logarithms.
  1208. * powl: (libc)Exponents and Logarithms.
  1209. * __ppc_get_timebase_freq: (libc)PowerPC.
  1210. * __ppc_get_timebase: (libc)PowerPC.
  1211. * __ppc_mdoio: (libc)PowerPC.
  1212. * __ppc_mdoom: (libc)PowerPC.
  1213. * __ppc_set_ppr_low: (libc)PowerPC.
  1214. * __ppc_set_ppr_med_high: (libc)PowerPC.
  1215. * __ppc_set_ppr_med: (libc)PowerPC.
  1216. * __ppc_set_ppr_med_low: (libc)PowerPC.
  1217. * __ppc_set_ppr_very_low: (libc)PowerPC.
  1218. * __ppc_yield: (libc)PowerPC.
  1219. * pread64: (libc)I/O Primitives.
  1220. * pread: (libc)I/O Primitives.
  1221. * printf: (libc)Formatted Output Functions.
  1222. * printf_size_info: (libc)Predefined Printf Handlers.
  1223. * printf_size: (libc)Predefined Printf Handlers.
  1224. * psignal: (libc)Signal Messages.
  1225. * pthread_getattr_default_np: (libc)Default Thread Attributes.
  1226. * pthread_getspecific: (libc)Thread-specific Data.
  1227. * pthread_key_create: (libc)Thread-specific Data.
  1228. * pthread_key_delete: (libc)Thread-specific Data.
  1229. * pthread_setattr_default_np: (libc)Default Thread Attributes.
  1230. * pthread_setspecific: (libc)Thread-specific Data.
  1231. * P_tmpdir: (libc)Temporary Files.
  1232. * ptsname: (libc)Allocation.
  1233. * ptsname_r: (libc)Allocation.
  1234. * putchar: (libc)Simple Output.
  1235. * putchar_unlocked: (libc)Simple Output.
  1236. * putc: (libc)Simple Output.
  1237. * putc_unlocked: (libc)Simple Output.
  1238. * putenv: (libc)Environment Access.
  1239. * putpwent: (libc)Writing a User Entry.
  1240. * puts: (libc)Simple Output.
  1241. * pututline: (libc)Manipulating the Database.
  1242. * pututxline: (libc)XPG Functions.
  1243. * putwchar: (libc)Simple Output.
  1244. * putwchar_unlocked: (libc)Simple Output.
  1245. * putwc: (libc)Simple Output.
  1246. * putwc_unlocked: (libc)Simple Output.
  1247. * putw: (libc)Simple Output.
  1248. * pwrite64: (libc)I/O Primitives.
  1249. * pwrite: (libc)I/O Primitives.
  1250. * qecvt: (libc)System V Number Conversion.
  1251. * qecvt_r: (libc)System V Number Conversion.
  1252. * qfcvt: (libc)System V Number Conversion.
  1253. * qfcvt_r: (libc)System V Number Conversion.
  1254. * qgcvt: (libc)System V Number Conversion.
  1255. * qsort: (libc)Array Sort Function.
  1256. * raise: (libc)Signaling Yourself.
  1257. * rand: (libc)ISO Random.
  1258. * RAND_MAX: (libc)ISO Random.
  1259. * random: (libc)BSD Random.
  1260. * random_r: (libc)BSD Random.
  1261. * rand_r: (libc)ISO Random.
  1262. * rawmemchr: (libc)Search Functions.
  1263. * readdir64: (libc)Reading/Closing Directory.
  1264. * readdir64_r: (libc)Reading/Closing Directory.
  1265. * readdir: (libc)Reading/Closing Directory.
  1266. * readdir_r: (libc)Reading/Closing Directory.
  1267. * read: (libc)I/O Primitives.
  1268. * readlink: (libc)Symbolic Links.
  1269. * readv: (libc)Scatter-Gather.
  1270. * realloc: (libc)Changing Block Size.
  1271. * realpath: (libc)Symbolic Links.
  1272. * recvfrom: (libc)Receiving Datagrams.
  1273. * recv: (libc)Receiving Data.
  1274. * recvmsg: (libc)Receiving Datagrams.
  1275. * RE_DUP_MAX: (libc)General Limits.
  1276. * regcomp: (libc)POSIX Regexp Compilation.
  1277. * regerror: (libc)Regexp Cleanup.
  1278. * regexec: (libc)Matching POSIX Regexps.
  1279. * regfree: (libc)Regexp Cleanup.
  1280. * register_printf_function: (libc)Registering New Conversions.
  1281. * remainderf: (libc)Remainder Functions.
  1282. * remainder: (libc)Remainder Functions.
  1283. * remainderl: (libc)Remainder Functions.
  1284. * remove: (libc)Deleting Files.
  1285. * rename: (libc)Renaming Files.
  1286. * rewinddir: (libc)Random Access Directory.
  1287. * rewind: (libc)File Positioning.
  1288. * rindex: (libc)Search Functions.
  1289. * rintf: (libc)Rounding Functions.
  1290. * rint: (libc)Rounding Functions.
  1291. * rintl: (libc)Rounding Functions.
  1292. * RLIM_INFINITY: (libc)Limits on Resources.
  1293. * rmdir: (libc)Deleting Files.
  1294. * R_OK: (libc)Testing File Access.
  1295. * roundevenf: (libc)Rounding Functions.
  1296. * roundeven: (libc)Rounding Functions.
  1297. * roundevenl: (libc)Rounding Functions.
  1298. * roundf: (libc)Rounding Functions.
  1299. * round: (libc)Rounding Functions.
  1300. * roundl: (libc)Rounding Functions.
  1301. * rpmatch: (libc)Yes-or-No Questions.
  1302. * SA_NOCLDSTOP: (libc)Flags for Sigaction.
  1303. * SA_ONSTACK: (libc)Flags for Sigaction.
  1304. * SA_RESTART: (libc)Flags for Sigaction.
  1305. * sbrk: (libc)Resizing the Data Segment.
  1306. * scalbf: (libc)Normalization Functions.
  1307. * scalb: (libc)Normalization Functions.
  1308. * scalbl: (libc)Normalization Functions.
  1309. * scalblnf: (libc)Normalization Functions.
  1310. * scalbln: (libc)Normalization Functions.
  1311. * scalblnl: (libc)Normalization Functions.
  1312. * scalbnf: (libc)Normalization Functions.
  1313. * scalbn: (libc)Normalization Functions.
  1314. * scalbnl: (libc)Normalization Functions.
  1315. * scandir64: (libc)Scanning Directory Content.
  1316. * scandir: (libc)Scanning Directory Content.
  1317. * scanf: (libc)Formatted Input Functions.
  1318. * sched_getaffinity: (libc)CPU Affinity.
  1319. * sched_getparam: (libc)Basic Scheduling Functions.
  1320. * sched_get_priority_max: (libc)Basic Scheduling Functions.
  1321. * sched_get_priority_min: (libc)Basic Scheduling Functions.
  1322. * sched_getscheduler: (libc)Basic Scheduling Functions.
  1323. * sched_rr_get_interval: (libc)Basic Scheduling Functions.
  1324. * sched_setaffinity: (libc)CPU Affinity.
  1325. * sched_setparam: (libc)Basic Scheduling Functions.
  1326. * sched_setscheduler: (libc)Basic Scheduling Functions.
  1327. * sched_yield: (libc)Basic Scheduling Functions.
  1328. * secure_getenv: (libc)Environment Access.
  1329. * seed48: (libc)SVID Random.
  1330. * seed48_r: (libc)SVID Random.
  1331. * SEEK_CUR: (libc)File Positioning.
  1332. * seekdir: (libc)Random Access Directory.
  1333. * SEEK_END: (libc)File Positioning.
  1334. * SEEK_SET: (libc)File Positioning.
  1335. * select: (libc)Waiting for I/O.
  1336. * sem_close: (libc)Semaphores.
  1337. * semctl: (libc)Semaphores.
  1338. * sem_destroy: (libc)Semaphores.
  1339. * semget: (libc)Semaphores.
  1340. * sem_getvalue: (libc)Semaphores.
  1341. * sem_init: (libc)Semaphores.
  1342. * sem_open: (libc)Semaphores.
  1343. * semop: (libc)Semaphores.
  1344. * sem_post: (libc)Semaphores.
  1345. * semtimedop: (libc)Semaphores.
  1346. * sem_timedwait: (libc)Semaphores.
  1347. * sem_trywait: (libc)Semaphores.
  1348. * sem_unlink: (libc)Semaphores.
  1349. * sem_wait: (libc)Semaphores.
  1350. * send: (libc)Sending Data.
  1351. * sendmsg: (libc)Receiving Datagrams.
  1352. * sendto: (libc)Sending Datagrams.
  1353. * setbuffer: (libc)Controlling Buffering.
  1354. * setbuf: (libc)Controlling Buffering.
  1355. * setcontext: (libc)System V contexts.
  1356. * setdomainname: (libc)Host Identification.
  1357. * setegid: (libc)Setting Groups.
  1358. * setenv: (libc)Environment Access.
  1359. * seteuid: (libc)Setting User ID.
  1360. * setfsent: (libc)fstab.
  1361. * setgid: (libc)Setting Groups.
  1362. * setgrent: (libc)Scanning All Groups.
  1363. * setgroups: (libc)Setting Groups.
  1364. * sethostent: (libc)Host Names.
  1365. * sethostid: (libc)Host Identification.
  1366. * sethostname: (libc)Host Identification.
  1367. * setitimer: (libc)Setting an Alarm.
  1368. * setjmp: (libc)Non-Local Details.
  1369. * setkey: (libc)DES Encryption.
  1370. * setkey_r: (libc)DES Encryption.
  1371. * setlinebuf: (libc)Controlling Buffering.
  1372. * setlocale: (libc)Setting the Locale.
  1373. * setlogmask: (libc)setlogmask.
  1374. * setmntent: (libc)mtab.
  1375. * setnetent: (libc)Networks Database.
  1376. * setnetgrent: (libc)Lookup Netgroup.
  1377. * setpayloadf: (libc)FP Bit Twiddling.
  1378. * setpayload: (libc)FP Bit Twiddling.
  1379. * setpayloadl: (libc)FP Bit Twiddling.
  1380. * setpayloadsigf: (libc)FP Bit Twiddling.
  1381. * setpayloadsig: (libc)FP Bit Twiddling.
  1382. * setpayloadsigl: (libc)FP Bit Twiddling.
  1383. * setpgid: (libc)Process Group Functions.
  1384. * setpgrp: (libc)Process Group Functions.
  1385. * setpriority: (libc)Traditional Scheduling Functions.
  1386. * setprotoent: (libc)Protocols Database.
  1387. * setpwent: (libc)Scanning All Users.
  1388. * setregid: (libc)Setting Groups.
  1389. * setreuid: (libc)Setting User ID.
  1390. * setrlimit64: (libc)Limits on Resources.
  1391. * setrlimit: (libc)Limits on Resources.
  1392. * setservent: (libc)Services Database.
  1393. * setsid: (libc)Process Group Functions.
  1394. * setsockopt: (libc)Socket Option Functions.
  1395. * setstate: (libc)BSD Random.
  1396. * setstate_r: (libc)BSD Random.
  1397. * settimeofday: (libc)High-Resolution Calendar.
  1398. * setuid: (libc)Setting User ID.
  1399. * setutent: (libc)Manipulating the Database.
  1400. * setutxent: (libc)XPG Functions.
  1401. * setvbuf: (libc)Controlling Buffering.
  1402. * shm_open: (libc)Memory-mapped I/O.
  1403. * shm_unlink: (libc)Memory-mapped I/O.
  1404. * shutdown: (libc)Closing a Socket.
  1405. * S_IFMT: (libc)Testing File Type.
  1406. * SIGABRT: (libc)Program Error Signals.
  1407. * sigaction: (libc)Advanced Signal Handling.
  1408. * sigaddset: (libc)Signal Sets.
  1409. * SIGALRM: (libc)Alarm Signals.
  1410. * sigaltstack: (libc)Signal Stack.
  1411. * sigblock: (libc)BSD Signal Handling.
  1412. * SIGBUS: (libc)Program Error Signals.
  1413. * SIGCHLD: (libc)Job Control Signals.
  1414. * SIGCLD: (libc)Job Control Signals.
  1415. * SIGCONT: (libc)Job Control Signals.
  1416. * sigdelset: (libc)Signal Sets.
  1417. * sigemptyset: (libc)Signal Sets.
  1418. * SIGEMT: (libc)Program Error Signals.
  1419. * SIG_ERR: (libc)Basic Signal Handling.
  1420. * sigfillset: (libc)Signal Sets.
  1421. * SIGFPE: (libc)Program Error Signals.
  1422. * SIGHUP: (libc)Termination Signals.
  1423. * SIGILL: (libc)Program Error Signals.
  1424. * SIGINFO: (libc)Miscellaneous Signals.
  1425. * siginterrupt: (libc)BSD Signal Handling.
  1426. * SIGINT: (libc)Termination Signals.
  1427. * SIGIO: (libc)Asynchronous I/O Signals.
  1428. * SIGIOT: (libc)Program Error Signals.
  1429. * sigismember: (libc)Signal Sets.
  1430. * SIGKILL: (libc)Termination Signals.
  1431. * siglongjmp: (libc)Non-Local Exits and Signals.
  1432. * SIGLOST: (libc)Operation Error Signals.
  1433. * sigmask: (libc)BSD Signal Handling.
  1434. * signal: (libc)Basic Signal Handling.
  1435. * signbit: (libc)FP Bit Twiddling.
  1436. * significandf: (libc)Normalization Functions.
  1437. * significand: (libc)Normalization Functions.
  1438. * significandl: (libc)Normalization Functions.
  1439. * sigpause: (libc)BSD Signal Handling.
  1440. * sigpending: (libc)Checking for Pending Signals.
  1441. * SIGPIPE: (libc)Operation Error Signals.
  1442. * SIGPOLL: (libc)Asynchronous I/O Signals.
  1443. * sigprocmask: (libc)Process Signal Mask.
  1444. * SIGPROF: (libc)Alarm Signals.
  1445. * SIGQUIT: (libc)Termination Signals.
  1446. * SIGSEGV: (libc)Program Error Signals.
  1447. * sigsetjmp: (libc)Non-Local Exits and Signals.
  1448. * sigsetmask: (libc)BSD Signal Handling.
  1449. * sigstack: (libc)Signal Stack.
  1450. * SIGSTOP: (libc)Job Control Signals.
  1451. * sigsuspend: (libc)Sigsuspend.
  1452. * SIGSYS: (libc)Program Error Signals.
  1453. * SIGTERM: (libc)Termination Signals.
  1454. * SIGTRAP: (libc)Program Error Signals.
  1455. * SIGTSTP: (libc)Job Control Signals.
  1456. * SIGTTIN: (libc)Job Control Signals.
  1457. * SIGTTOU: (libc)Job Control Signals.
  1458. * SIGURG: (libc)Asynchronous I/O Signals.
  1459. * SIGUSR1: (libc)Miscellaneous Signals.
  1460. * SIGUSR2: (libc)Miscellaneous Signals.
  1461. * SIGVTALRM: (libc)Alarm Signals.
  1462. * SIGWINCH: (libc)Miscellaneous Signals.
  1463. * SIGXCPU: (libc)Operation Error Signals.
  1464. * SIGXFSZ: (libc)Operation Error Signals.
  1465. * sincosf: (libc)Trig Functions.
  1466. * sincos: (libc)Trig Functions.
  1467. * sincosl: (libc)Trig Functions.
  1468. * sinf: (libc)Trig Functions.
  1469. * sinhf: (libc)Hyperbolic Functions.
  1470. * sinh: (libc)Hyperbolic Functions.
  1471. * sinhl: (libc)Hyperbolic Functions.
  1472. * sin: (libc)Trig Functions.
  1473. * sinl: (libc)Trig Functions.
  1474. * S_ISBLK: (libc)Testing File Type.
  1475. * S_ISCHR: (libc)Testing File Type.
  1476. * S_ISDIR: (libc)Testing File Type.
  1477. * S_ISFIFO: (libc)Testing File Type.
  1478. * S_ISLNK: (libc)Testing File Type.
  1479. * S_ISREG: (libc)Testing File Type.
  1480. * S_ISSOCK: (libc)Testing File Type.
  1481. * sleep: (libc)Sleeping.
  1482. * SNANF: (libc)Infinity and NaN.
  1483. * SNAN: (libc)Infinity and NaN.
  1484. * SNANL: (libc)Infinity and NaN.
  1485. * snprintf: (libc)Formatted Output Functions.
  1486. * SOCK_DGRAM: (libc)Communication Styles.
  1487. * socket: (libc)Creating a Socket.
  1488. * socketpair: (libc)Socket Pairs.
  1489. * SOCK_RAW: (libc)Communication Styles.
  1490. * SOCK_RDM: (libc)Communication Styles.
  1491. * SOCK_SEQPACKET: (libc)Communication Styles.
  1492. * SOCK_STREAM: (libc)Communication Styles.
  1493. * SOL_SOCKET: (libc)Socket-Level Options.
  1494. * sprintf: (libc)Formatted Output Functions.
  1495. * sqrtf: (libc)Exponents and Logarithms.
  1496. * sqrt: (libc)Exponents and Logarithms.
  1497. * sqrtl: (libc)Exponents and Logarithms.
  1498. * srand48: (libc)SVID Random.
  1499. * srand48_r: (libc)SVID Random.
  1500. * srand: (libc)ISO Random.
  1501. * srandom: (libc)BSD Random.
  1502. * srandom_r: (libc)BSD Random.
  1503. * sscanf: (libc)Formatted Input Functions.
  1504. * ssignal: (libc)Basic Signal Handling.
  1505. * SSIZE_MAX: (libc)General Limits.
  1506. * stat64: (libc)Reading Attributes.
  1507. * stat: (libc)Reading Attributes.
  1508. * stime: (libc)Simple Calendar Time.
  1509. * stpcpy: (libc)Copying Strings and Arrays.
  1510. * stpncpy: (libc)Truncating Strings.
  1511. * strcasecmp: (libc)String/Array Comparison.
  1512. * strcasestr: (libc)Search Functions.
  1513. * strcat: (libc)Concatenating Strings.
  1514. * strchr: (libc)Search Functions.
  1515. * strchrnul: (libc)Search Functions.
  1516. * strcmp: (libc)String/Array Comparison.
  1517. * strcoll: (libc)Collation Functions.
  1518. * strcpy: (libc)Copying Strings and Arrays.
  1519. * strcspn: (libc)Search Functions.
  1520. * strdupa: (libc)Copying Strings and Arrays.
  1521. * strdup: (libc)Copying Strings and Arrays.
  1522. * STREAM_MAX: (libc)General Limits.
  1523. * strerror: (libc)Error Messages.
  1524. * strerror_r: (libc)Error Messages.
  1525. * strfmon: (libc)Formatting Numbers.
  1526. * strfromd: (libc)Printing of Floats.
  1527. * strfromf: (libc)Printing of Floats.
  1528. * strfroml: (libc)Printing of Floats.
  1529. * strfry: (libc)strfry.
  1530. * strftime: (libc)Formatting Calendar Time.
  1531. * strlen: (libc)String Length.
  1532. * strncasecmp: (libc)String/Array Comparison.
  1533. * strncat: (libc)Truncating Strings.
  1534. * strncmp: (libc)String/Array Comparison.
  1535. * strncpy: (libc)Truncating Strings.
  1536. * strndupa: (libc)Truncating Strings.
  1537. * strndup: (libc)Truncating Strings.
  1538. * strnlen: (libc)String Length.
  1539. * strpbrk: (libc)Search Functions.
  1540. * strptime: (libc)Low-Level Time String Parsing.
  1541. * strrchr: (libc)Search Functions.
  1542. * strsep: (libc)Finding Tokens in a String.
  1543. * strsignal: (libc)Signal Messages.
  1544. * strspn: (libc)Search Functions.
  1545. * strstr: (libc)Search Functions.
  1546. * strtod: (libc)Parsing of Floats.
  1547. * strtof: (libc)Parsing of Floats.
  1548. * strtoimax: (libc)Parsing of Integers.
  1549. * strtok: (libc)Finding Tokens in a String.
  1550. * strtok_r: (libc)Finding Tokens in a String.
  1551. * strtold: (libc)Parsing of Floats.
  1552. * strtol: (libc)Parsing of Integers.
  1553. * strtoll: (libc)Parsing of Integers.
  1554. * strtoq: (libc)Parsing of Integers.
  1555. * strtoul: (libc)Parsing of Integers.
  1556. * strtoull: (libc)Parsing of Integers.
  1557. * strtoumax: (libc)Parsing of Integers.
  1558. * strtouq: (libc)Parsing of Integers.
  1559. * strverscmp: (libc)String/Array Comparison.
  1560. * strxfrm: (libc)Collation Functions.
  1561. * stty: (libc)BSD Terminal Modes.
  1562. * S_TYPEISMQ: (libc)Testing File Type.
  1563. * S_TYPEISSEM: (libc)Testing File Type.
  1564. * S_TYPEISSHM: (libc)Testing File Type.
  1565. * SUN_LEN: (libc)Local Namespace Details.
  1566. * swapcontext: (libc)System V contexts.
  1567. * swprintf: (libc)Formatted Output Functions.
  1568. * swscanf: (libc)Formatted Input Functions.
  1569. * symlink: (libc)Symbolic Links.
  1570. * sync: (libc)Synchronizing I/O.
  1571. * syscall: (libc)System Calls.
  1572. * sysconf: (libc)Sysconf Definition.
  1573. * sysctl: (libc)System Parameters.
  1574. * syslog: (libc)syslog; vsyslog.
  1575. * system: (libc)Running a Command.
  1576. * sysv_signal: (libc)Basic Signal Handling.
  1577. * tanf: (libc)Trig Functions.
  1578. * tanhf: (libc)Hyperbolic Functions.
  1579. * tanh: (libc)Hyperbolic Functions.
  1580. * tanhl: (libc)Hyperbolic Functions.
  1581. * tan: (libc)Trig Functions.
  1582. * tanl: (libc)Trig Functions.
  1583. * tcdrain: (libc)Line Control.
  1584. * tcflow: (libc)Line Control.
  1585. * tcflush: (libc)Line Control.
  1586. * tcgetattr: (libc)Mode Functions.
  1587. * tcgetpgrp: (libc)Terminal Access Functions.
  1588. * tcgetsid: (libc)Terminal Access Functions.
  1589. * tcsendbreak: (libc)Line Control.
  1590. * tcsetattr: (libc)Mode Functions.
  1591. * tcsetpgrp: (libc)Terminal Access Functions.
  1592. * tdelete: (libc)Tree Search Function.
  1593. * tdestroy: (libc)Tree Search Function.
  1594. * telldir: (libc)Random Access Directory.
  1595. * tempnam: (libc)Temporary Files.
  1596. * textdomain: (libc)Locating gettext catalog.
  1597. * tfind: (libc)Tree Search Function.
  1598. * tgammaf: (libc)Special Functions.
  1599. * tgamma: (libc)Special Functions.
  1600. * tgammal: (libc)Special Functions.
  1601. * timegm: (libc)Broken-down Time.
  1602. * time: (libc)Simple Calendar Time.
  1603. * timelocal: (libc)Broken-down Time.
  1604. * times: (libc)Processor Time.
  1605. * tmpfile64: (libc)Temporary Files.
  1606. * tmpfile: (libc)Temporary Files.
  1607. * TMP_MAX: (libc)Temporary Files.
  1608. * tmpnam: (libc)Temporary Files.
  1609. * tmpnam_r: (libc)Temporary Files.
  1610. * toascii: (libc)Case Conversion.
  1611. * _tolower: (libc)Case Conversion.
  1612. * tolower: (libc)Case Conversion.
  1613. * TOSTOP: (libc)Local Modes.
  1614. * totalorderf: (libc)FP Comparison Functions.
  1615. * totalorder: (libc)FP Comparison Functions.
  1616. * totalorderl: (libc)FP Comparison Functions.
  1617. * totalordermagf: (libc)FP Comparison Functions.
  1618. * totalordermag: (libc)FP Comparison Functions.
  1619. * totalordermagl: (libc)FP Comparison Functions.
  1620. * _toupper: (libc)Case Conversion.
  1621. * toupper: (libc)Case Conversion.
  1622. * towctrans: (libc)Wide Character Case Conversion.
  1623. * towlower: (libc)Wide Character Case Conversion.
  1624. * towupper: (libc)Wide Character Case Conversion.
  1625. * truncate64: (libc)File Size.
  1626. * truncate: (libc)File Size.
  1627. * truncf: (libc)Rounding Functions.
  1628. * trunc: (libc)Rounding Functions.
  1629. * truncl: (libc)Rounding Functions.
  1630. * tsearch: (libc)Tree Search Function.
  1631. * ttyname: (libc)Is It a Terminal.
  1632. * ttyname_r: (libc)Is It a Terminal.
  1633. * twalk: (libc)Tree Search Function.
  1634. * TZNAME_MAX: (libc)General Limits.
  1635. * tzset: (libc)Time Zone Functions.
  1636. * ufromfpf: (libc)Rounding Functions.
  1637. * ufromfp: (libc)Rounding Functions.
  1638. * ufromfpl: (libc)Rounding Functions.
  1639. * ufromfpxf: (libc)Rounding Functions.
  1640. * ufromfpx: (libc)Rounding Functions.
  1641. * ufromfpxl: (libc)Rounding Functions.
  1642. * ulimit: (libc)Limits on Resources.
  1643. * umask: (libc)Setting Permissions.
  1644. * umount2: (libc)Mount-Unmount-Remount.
  1645. * umount: (libc)Mount-Unmount-Remount.
  1646. * uname: (libc)Platform Type.
  1647. * ungetc: (libc)How Unread.
  1648. * ungetwc: (libc)How Unread.
  1649. * unlink: (libc)Deleting Files.
  1650. * unlockpt: (libc)Allocation.
  1651. * unsetenv: (libc)Environment Access.
  1652. * updwtmp: (libc)Manipulating the Database.
  1653. * utime: (libc)File Times.
  1654. * utimes: (libc)File Times.
  1655. * utmpname: (libc)Manipulating the Database.
  1656. * utmpxname: (libc)XPG Functions.
  1657. * va_arg: (libc)Argument Macros.
  1658. * __va_copy: (libc)Argument Macros.
  1659. * va_copy: (libc)Argument Macros.
  1660. * va_end: (libc)Argument Macros.
  1661. * valloc: (libc)Aligned Memory Blocks.
  1662. * vasprintf: (libc)Variable Arguments Output.
  1663. * va_start: (libc)Argument Macros.
  1664. * VDISCARD: (libc)Other Special.
  1665. * VDSUSP: (libc)Signal Characters.
  1666. * VEOF: (libc)Editing Characters.
  1667. * VEOL2: (libc)Editing Characters.
  1668. * VEOL: (libc)Editing Characters.
  1669. * VERASE: (libc)Editing Characters.
  1670. * verr: (libc)Error Messages.
  1671. * verrx: (libc)Error Messages.
  1672. * versionsort64: (libc)Scanning Directory Content.
  1673. * versionsort: (libc)Scanning Directory Content.
  1674. * vfork: (libc)Creating a Process.
  1675. * vfprintf: (libc)Variable Arguments Output.
  1676. * vfscanf: (libc)Variable Arguments Input.
  1677. * vfwprintf: (libc)Variable Arguments Output.
  1678. * vfwscanf: (libc)Variable Arguments Input.
  1679. * VINTR: (libc)Signal Characters.
  1680. * VKILL: (libc)Editing Characters.
  1681. * vlimit: (libc)Limits on Resources.
  1682. * VLNEXT: (libc)Other Special.
  1683. * VMIN: (libc)Noncanonical Input.
  1684. * vprintf: (libc)Variable Arguments Output.
  1685. * VQUIT: (libc)Signal Characters.
  1686. * VREPRINT: (libc)Editing Characters.
  1687. * vscanf: (libc)Variable Arguments Input.
  1688. * vsnprintf: (libc)Variable Arguments Output.
  1689. * vsprintf: (libc)Variable Arguments Output.
  1690. * vsscanf: (libc)Variable Arguments Input.
  1691. * VSTART: (libc)Start/Stop Characters.
  1692. * VSTATUS: (libc)Other Special.
  1693. * VSTOP: (libc)Start/Stop Characters.
  1694. * VSUSP: (libc)Signal Characters.
  1695. * vswprintf: (libc)Variable Arguments Output.
  1696. * vswscanf: (libc)Variable Arguments Input.
  1697. * vsyslog: (libc)syslog; vsyslog.
  1698. * VTIME: (libc)Noncanonical Input.
  1699. * vtimes: (libc)Resource Usage.
  1700. * vwarn: (libc)Error Messages.
  1701. * vwarnx: (libc)Error Messages.
  1702. * VWERASE: (libc)Editing Characters.
  1703. * vwprintf: (libc)Variable Arguments Output.
  1704. * vwscanf: (libc)Variable Arguments Input.
  1705. * wait3: (libc)BSD Wait Functions.
  1706. * wait4: (libc)Process Completion.
  1707. * wait: (libc)Process Completion.
  1708. * waitpid: (libc)Process Completion.
  1709. * warn: (libc)Error Messages.
  1710. * warnx: (libc)Error Messages.
  1711. * WCHAR_MAX: (libc)Extended Char Intro.
  1712. * WCHAR_MIN: (libc)Extended Char Intro.
  1713. * WCOREDUMP: (libc)Process Completion Status.
  1714. * wcpcpy: (libc)Copying Strings and Arrays.
  1715. * wcpncpy: (libc)Truncating Strings.
  1716. * wcrtomb: (libc)Converting a Character.
  1717. * wcscasecmp: (libc)String/Array Comparison.
  1718. * wcscat: (libc)Concatenating Strings.
  1719. * wcschr: (libc)Search Functions.
  1720. * wcschrnul: (libc)Search Functions.
  1721. * wcscmp: (libc)String/Array Comparison.
  1722. * wcscoll: (libc)Collation Functions.
  1723. * wcscpy: (libc)Copying Strings and Arrays.
  1724. * wcscspn: (libc)Search Functions.
  1725. * wcsdup: (libc)Copying Strings and Arrays.
  1726. * wcsftime: (libc)Formatting Calendar Time.
  1727. * wcslen: (libc)String Length.
  1728. * wcsncasecmp: (libc)String/Array Comparison.
  1729. * wcsncat: (libc)Truncating Strings.
  1730. * wcsncmp: (libc)String/Array Comparison.
  1731. * wcsncpy: (libc)Truncating Strings.
  1732. * wcsnlen: (libc)String Length.
  1733. * wcsnrtombs: (libc)Converting Strings.
  1734. * wcspbrk: (libc)Search Functions.
  1735. * wcsrchr: (libc)Search Functions.
  1736. * wcsrtombs: (libc)Converting Strings.
  1737. * wcsspn: (libc)Search Functions.
  1738. * wcsstr: (libc)Search Functions.
  1739. * wcstod: (libc)Parsing of Floats.
  1740. * wcstof: (libc)Parsing of Floats.
  1741. * wcstoimax: (libc)Parsing of Integers.
  1742. * wcstok: (libc)Finding Tokens in a String.
  1743. * wcstold: (libc)Parsing of Floats.
  1744. * wcstol: (libc)Parsing of Integers.
  1745. * wcstoll: (libc)Parsing of Integers.
  1746. * wcstombs: (libc)Non-reentrant String Conversion.
  1747. * wcstoq: (libc)Parsing of Integers.
  1748. * wcstoul: (libc)Parsing of Integers.
  1749. * wcstoull: (libc)Parsing of Integers.
  1750. * wcstoumax: (libc)Parsing of Integers.
  1751. * wcstouq: (libc)Parsing of Integers.
  1752. * wcswcs: (libc)Search Functions.
  1753. * wcsxfrm: (libc)Collation Functions.
  1754. * wctob: (libc)Converting a Character.
  1755. * wctomb: (libc)Non-reentrant Character Conversion.
  1756. * wctrans: (libc)Wide Character Case Conversion.
  1757. * wctype: (libc)Classification of Wide Characters.
  1758. * WEOF: (libc)EOF and Errors.
  1759. * WEOF: (libc)Extended Char Intro.
  1760. * WEXITSTATUS: (libc)Process Completion Status.
  1761. * WIFEXITED: (libc)Process Completion Status.
  1762. * WIFSIGNALED: (libc)Process Completion Status.
  1763. * WIFSTOPPED: (libc)Process Completion Status.
  1764. * wmemchr: (libc)Search Functions.
  1765. * wmemcmp: (libc)String/Array Comparison.
  1766. * wmemcpy: (libc)Copying Strings and Arrays.
  1767. * wmemmove: (libc)Copying Strings and Arrays.
  1768. * wmempcpy: (libc)Copying Strings and Arrays.
  1769. * wmemset: (libc)Copying Strings and Arrays.
  1770. * W_OK: (libc)Testing File Access.
  1771. * wordexp: (libc)Calling Wordexp.
  1772. * wordfree: (libc)Calling Wordexp.
  1773. * wprintf: (libc)Formatted Output Functions.
  1774. * write: (libc)I/O Primitives.
  1775. * writev: (libc)Scatter-Gather.
  1776. * wscanf: (libc)Formatted Input Functions.
  1777. * WSTOPSIG: (libc)Process Completion Status.
  1778. * WTERMSIG: (libc)Process Completion Status.
  1779. * X_OK: (libc)Testing File Access.
  1780. * y0f: (libc)Special Functions.
  1781. * y0: (libc)Special Functions.
  1782. * y0l: (libc)Special Functions.
  1783. * y1f: (libc)Special Functions.
  1784. * y1: (libc)Special Functions.
  1785. * y1l: (libc)Special Functions.
  1786. * ynf: (libc)Special Functions.
  1787. * yn: (libc)Special Functions.
  1788. * ynl: (libc)Special Functions.
  1789. END-INFO-DIR-ENTRY
  1790. 
  1791. File: libc.info, Node: Inter-Process Communication, Next: Job Control, Prev: Processes, Up: Top
  1792. 27 Inter-Process Communication
  1793. ******************************
  1794. This chapter describes the GNU C Library inter-process communication
  1795. primitives.
  1796. * Menu:
  1797. * Semaphores:: Support for creating and managing semaphores
  1798. 
  1799. File: libc.info, Node: Semaphores, Up: Inter-Process Communication
  1800. 27.1 Semaphores
  1801. ===============
  1802. The GNU C Library implements the semaphore APIs as defined in POSIX and
  1803. System V. Semaphores can be used by multiple processes to coordinate
  1804. shared resources. The following is a complete list of the semaphore
  1805. functions provided by the GNU C Library.
  1806. 27.1.1 System V Semaphores
  1807. --------------------------
  1808. -- Function: int semctl (int SEMID, int SEMNUM, int CMD);
  1809. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt/linux | *Note
  1810. POSIX Safety Concepts::.
  1811. -- Function: int semget (key_t KEY, int NSEMS, int SEMFLG);
  1812. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1813. Concepts::.
  1814. -- Function: int semop (int SEMID, struct sembuf *SOPS, size_t NSOPS);
  1815. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1816. Concepts::.
  1817. -- Function: int semtimedop (int SEMID, struct sembuf *SOPS, size_t
  1818. NSOPS, const struct timespec *TIMEOUT);
  1819. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1820. Concepts::.
  1821. 27.1.2 POSIX Semaphores
  1822. -----------------------
  1823. -- Function: int sem_init (sem_t *SEM, int PSHARED, unsigned int
  1824. VALUE);
  1825. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  1826. Safety Concepts::.
  1827. -- Function: int sem_destroy (sem_t *SEM);
  1828. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1829. Concepts::.
  1830. -- Function: sem_t *sem_open (const char *NAME, int OFLAG, ...);
  1831. Preliminary: | MT-Safe | AS-Unsafe init | AC-Unsafe init | *Note
  1832. POSIX Safety Concepts::.
  1833. -- Function: int sem_close (sem_t *SEM);
  1834. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  1835. POSIX Safety Concepts::.
  1836. -- Function: int sem_unlink (const char *NAME);
  1837. Preliminary: | MT-Safe | AS-Unsafe init | AC-Unsafe corrupt | *Note
  1838. POSIX Safety Concepts::.
  1839. -- Function: int sem_wait (sem_t *SEM);
  1840. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  1841. Safety Concepts::.
  1842. -- Function: int sem_timedwait (sem_t *SEM, const struct timespec
  1843. *ABSTIME);
  1844. Preliminary: | MT-Safe | AS-Safe | AC-Unsafe corrupt | *Note POSIX
  1845. Safety Concepts::.
  1846. -- Function: int sem_trywait (sem_t *SEM);
  1847. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1848. Concepts::.
  1849. -- Function: int sem_post (sem_t *SEM);
  1850. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1851. Concepts::.
  1852. -- Function: int sem_getvalue (sem_t *SEM, int *SVAL);
  1853. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  1854. Concepts::.
  1855. 
  1856. File: libc.info, Node: Job Control, Next: Name Service Switch, Prev: Inter-Process Communication, Up: Top
  1857. 28 Job Control
  1858. **************
  1859. "Job control" refers to the protocol for allowing a user to move between
  1860. multiple "process groups" (or "jobs") within a single "login session".
  1861. The job control facilities are set up so that appropriate behavior for
  1862. most programs happens automatically and they need not do anything
  1863. special about job control. So you can probably ignore the material in
  1864. this chapter unless you are writing a shell or login program.
  1865. You need to be familiar with concepts relating to process creation
  1866. (*note Process Creation Concepts::) and signal handling (*note Signal
  1867. Handling::) in order to understand this material presented in this
  1868. chapter.
  1869. * Menu:
  1870. * Concepts of Job Control:: Jobs can be controlled by a shell.
  1871. * Job Control is Optional:: Not all POSIX systems support job control.
  1872. * Controlling Terminal:: How a process gets its controlling terminal.
  1873. * Access to the Terminal:: How processes share the controlling terminal.
  1874. * Orphaned Process Groups:: Jobs left after the user logs out.
  1875. * Implementing a Shell:: What a shell must do to implement job control.
  1876. * Functions for Job Control:: Functions to control process groups.
  1877. 
  1878. File: libc.info, Node: Concepts of Job Control, Next: Job Control is Optional, Up: Job Control
  1879. 28.1 Concepts of Job Control
  1880. ============================
  1881. The fundamental purpose of an interactive shell is to read commands from
  1882. the user’s terminal and create processes to execute the programs
  1883. specified by those commands. It can do this using the ‘fork’ (*note
  1884. Creating a Process::) and ‘exec’ (*note Executing a File::) functions.
  1885. A single command may run just one process—but often one command uses
  1886. several processes. If you use the ‘|’ operator in a shell command, you
  1887. explicitly request several programs in their own processes. But even if
  1888. you run just one program, it can use multiple processes internally. For
  1889. example, a single compilation command such as ‘cc -c foo.c’ typically
  1890. uses four processes (though normally only two at any given time). If
  1891. you run ‘make’, its job is to run other programs in separate processes.
  1892. The processes belonging to a single command are called a "process
  1893. group" or "job". This is so that you can operate on all of them at
  1894. once. For example, typing ‘C-c’ sends the signal ‘SIGINT’ to terminate
  1895. all the processes in the foreground process group.
  1896. A "session" is a larger group of processes. Normally all the
  1897. processes that stem from a single login belong to the same session.
  1898. Every process belongs to a process group. When a process is created,
  1899. it becomes a member of the same process group and session as its parent
  1900. process. You can put it in another process group using the ‘setpgid’
  1901. function, provided the process group belongs to the same session.
  1902. The only way to put a process in a different session is to make it
  1903. the initial process of a new session, or a "session leader", using the
  1904. ‘setsid’ function. This also puts the session leader into a new process
  1905. group, and you can’t move it out of that process group again.
  1906. Usually, new sessions are created by the system login program, and
  1907. the session leader is the process running the user’s login shell.
  1908. A shell that supports job control must arrange to control which job
  1909. can use the terminal at any time. Otherwise there might be multiple
  1910. jobs trying to read from the terminal at once, and confusion about which
  1911. process should receive the input typed by the user. To prevent this,
  1912. the shell must cooperate with the terminal driver using the protocol
  1913. described in this chapter.
  1914. The shell can give unlimited access to the controlling terminal to
  1915. only one process group at a time. This is called the "foreground job"
  1916. on that controlling terminal. Other process groups managed by the shell
  1917. that are executing without such access to the terminal are called
  1918. "background jobs".
  1919. If a background job needs to read from its controlling terminal, it
  1920. is "stopped" by the terminal driver; if the ‘TOSTOP’ mode is set,
  1921. likewise for writing. The user can stop a foreground job by typing the
  1922. SUSP character (*note Special Characters::) and a program can stop any
  1923. job by sending it a ‘SIGSTOP’ signal. It’s the responsibility of the
  1924. shell to notice when jobs stop, to notify the user about them, and to
  1925. provide mechanisms for allowing the user to interactively continue
  1926. stopped jobs and switch jobs between foreground and background.
  1927. *Note Access to the Terminal::, for more information about I/O to the
  1928. controlling terminal.
  1929. 
  1930. File: libc.info, Node: Job Control is Optional, Next: Controlling Terminal, Prev: Concepts of Job Control, Up: Job Control
  1931. 28.2 Job Control is Optional
  1932. ============================
  1933. Not all operating systems support job control. GNU systems do support
  1934. job control, but if you are using the GNU C Library on some other
  1935. system, that system may not support job control itself.
  1936. You can use the ‘_POSIX_JOB_CONTROL’ macro to test at compile-time
  1937. whether the system supports job control. *Note System Options::.
  1938. If job control is not supported, then there can be only one process
  1939. group per session, which behaves as if it were always in the foreground.
  1940. The functions for creating additional process groups simply fail with
  1941. the error code ‘ENOSYS’.
  1942. The macros naming the various job control signals (*note Job Control
  1943. Signals::) are defined even if job control is not supported. However,
  1944. the system never generates these signals, and attempts to send a job
  1945. control signal or examine or specify their actions report errors or do
  1946. nothing.
  1947. 
  1948. File: libc.info, Node: Controlling Terminal, Next: Access to the Terminal, Prev: Job Control is Optional, Up: Job Control
  1949. 28.3 Controlling Terminal of a Process
  1950. ======================================
  1951. One of the attributes of a process is its controlling terminal. Child
  1952. processes created with ‘fork’ inherit the controlling terminal from
  1953. their parent process. In this way, all the processes in a session
  1954. inherit the controlling terminal from the session leader. A session
  1955. leader that has control of a terminal is called the "controlling
  1956. process" of that terminal.
  1957. You generally do not need to worry about the exact mechanism used to
  1958. allocate a controlling terminal to a session, since it is done for you
  1959. by the system when you log in.
  1960. An individual process disconnects from its controlling terminal when
  1961. it calls ‘setsid’ to become the leader of a new session. *Note Process
  1962. Group Functions::.
  1963. 
  1964. File: libc.info, Node: Access to the Terminal, Next: Orphaned Process Groups, Prev: Controlling Terminal, Up: Job Control
  1965. 28.4 Access to the Controlling Terminal
  1966. =======================================
  1967. Processes in the foreground job of a controlling terminal have
  1968. unrestricted access to that terminal; background processes do not. This
  1969. section describes in more detail what happens when a process in a
  1970. background job tries to access its controlling terminal.
  1971. When a process in a background job tries to read from its controlling
  1972. terminal, the process group is usually sent a ‘SIGTTIN’ signal. This
  1973. normally causes all of the processes in that group to stop (unless they
  1974. handle the signal and don’t stop themselves). However, if the reading
  1975. process is ignoring or blocking this signal, then ‘read’ fails with an
  1976. ‘EIO’ error instead.
  1977. Similarly, when a process in a background job tries to write to its
  1978. controlling terminal, the default behavior is to send a ‘SIGTTOU’ signal
  1979. to the process group. However, the behavior is modified by the ‘TOSTOP’
  1980. bit of the local modes flags (*note Local Modes::). If this bit is not
  1981. set (which is the default), then writing to the controlling terminal is
  1982. always permitted without sending a signal. Writing is also permitted if
  1983. the ‘SIGTTOU’ signal is being ignored or blocked by the writing process.
  1984. Most other terminal operations that a program can do are treated as
  1985. reading or as writing. (The description of each operation should say
  1986. which.)
  1987. For more information about the primitive ‘read’ and ‘write’
  1988. functions, see *note I/O Primitives::.
  1989. 
  1990. File: libc.info, Node: Orphaned Process Groups, Next: Implementing a Shell, Prev: Access to the Terminal, Up: Job Control
  1991. 28.5 Orphaned Process Groups
  1992. ============================
  1993. When a controlling process terminates, its terminal becomes free and a
  1994. new session can be established on it. (In fact, another user could log
  1995. in on the terminal.) This could cause a problem if any processes from
  1996. the old session are still trying to use that terminal.
  1997. To prevent problems, process groups that continue running even after
  1998. the session leader has terminated are marked as "orphaned process
  1999. groups".
  2000. When a process group becomes an orphan, its processes are sent a
  2001. ‘SIGHUP’ signal. Ordinarily, this causes the processes to terminate.
  2002. However, if a program ignores this signal or establishes a handler for
  2003. it (*note Signal Handling::), it can continue running as in the orphan
  2004. process group even after its controlling process terminates; but it
  2005. still cannot access the terminal any more.
  2006. 
  2007. File: libc.info, Node: Implementing a Shell, Next: Functions for Job Control, Prev: Orphaned Process Groups, Up: Job Control
  2008. 28.6 Implementing a Job Control Shell
  2009. =====================================
  2010. This section describes what a shell must do to implement job control, by
  2011. presenting an extensive sample program to illustrate the concepts
  2012. involved.
  2013. * Menu:
  2014. * Data Structures:: Introduction to the sample shell.
  2015. * Initializing the Shell:: What the shell must do to take
  2016. responsibility for job control.
  2017. * Launching Jobs:: Creating jobs to execute commands.
  2018. * Foreground and Background:: Putting a job in foreground of background.
  2019. * Stopped and Terminated Jobs:: Reporting job status.
  2020. * Continuing Stopped Jobs:: How to continue a stopped job in
  2021. the foreground or background.
  2022. * Missing Pieces:: Other parts of the shell.
  2023. 
  2024. File: libc.info, Node: Data Structures, Next: Initializing the Shell, Up: Implementing a Shell
  2025. 28.6.1 Data Structures for the Shell
  2026. ------------------------------------
  2027. All of the program examples included in this chapter are part of a
  2028. simple shell program. This section presents data structures and utility
  2029. functions which are used throughout the example.
  2030. The sample shell deals mainly with two data structures. The ‘job’
  2031. type contains information about a job, which is a set of subprocesses
  2032. linked together with pipes. The ‘process’ type holds information about
  2033. a single subprocess. Here are the relevant data structure declarations:
  2034. /* A process is a single process. */
  2035. typedef struct process
  2036. {
  2037. struct process *next; /* next process in pipeline */
  2038. char **argv; /* for exec */
  2039. pid_t pid; /* process ID */
  2040. char completed; /* true if process has completed */
  2041. char stopped; /* true if process has stopped */
  2042. int status; /* reported status value */
  2043. } process;
  2044. /* A job is a pipeline of processes. */
  2045. typedef struct job
  2046. {
  2047. struct job *next; /* next active job */
  2048. char *command; /* command line, used for messages */
  2049. process *first_process; /* list of processes in this job */
  2050. pid_t pgid; /* process group ID */
  2051. char notified; /* true if user told about stopped job */
  2052. struct termios tmodes; /* saved terminal modes */
  2053. int stdin, stdout, stderr; /* standard i/o channels */
  2054. } job;
  2055. /* The active jobs are linked into a list. This is its head. */
  2056. job *first_job = NULL;
  2057. Here are some utility functions that are used for operating on ‘job’
  2058. objects.
  2059. /* Find the active job with the indicated PGID. */
  2060. job *
  2061. find_job (pid_t pgid)
  2062. {
  2063. job *j;
  2064. for (j = first_job; j; j = j->next)
  2065. if (j->pgid == pgid)
  2066. return j;
  2067. return NULL;
  2068. }
  2069. /* Return true if all processes in the job have stopped or completed. */
  2070. int
  2071. job_is_stopped (job *j)
  2072. {
  2073. process *p;
  2074. for (p = j->first_process; p; p = p->next)
  2075. if (!p->completed && !p->stopped)
  2076. return 0;
  2077. return 1;
  2078. }
  2079. /* Return true if all processes in the job have completed. */
  2080. int
  2081. job_is_completed (job *j)
  2082. {
  2083. process *p;
  2084. for (p = j->first_process; p; p = p->next)
  2085. if (!p->completed)
  2086. return 0;
  2087. return 1;
  2088. }
  2089. 
  2090. File: libc.info, Node: Initializing the Shell, Next: Launching Jobs, Prev: Data Structures, Up: Implementing a Shell
  2091. 28.6.2 Initializing the Shell
  2092. -----------------------------
  2093. When a shell program that normally performs job control is started, it
  2094. has to be careful in case it has been invoked from another shell that is
  2095. already doing its own job control.
  2096. A subshell that runs interactively has to ensure that it has been
  2097. placed in the foreground by its parent shell before it can enable job
  2098. control itself. It does this by getting its initial process group ID
  2099. with the ‘getpgrp’ function, and comparing it to the process group ID of
  2100. the current foreground job associated with its controlling terminal
  2101. (which can be retrieved using the ‘tcgetpgrp’ function).
  2102. If the subshell is not running as a foreground job, it must stop
  2103. itself by sending a ‘SIGTTIN’ signal to its own process group. It may
  2104. not arbitrarily put itself into the foreground; it must wait for the
  2105. user to tell the parent shell to do this. If the subshell is continued
  2106. again, it should repeat the check and stop itself again if it is still
  2107. not in the foreground.
  2108. Once the subshell has been placed into the foreground by its parent
  2109. shell, it can enable its own job control. It does this by calling
  2110. ‘setpgid’ to put itself into its own process group, and then calling
  2111. ‘tcsetpgrp’ to place this process group into the foreground.
  2112. When a shell enables job control, it should set itself to ignore all
  2113. the job control stop signals so that it doesn’t accidentally stop
  2114. itself. You can do this by setting the action for all the stop signals
  2115. to ‘SIG_IGN’.
  2116. A subshell that runs non-interactively cannot and should not support
  2117. job control. It must leave all processes it creates in the same process
  2118. group as the shell itself; this allows the non-interactive shell and its
  2119. child processes to be treated as a single job by the parent shell. This
  2120. is easy to do—just don’t use any of the job control primitives—but you
  2121. must remember to make the shell do it.
  2122. Here is the initialization code for the sample shell that shows how
  2123. to do all of this.
  2124. /* Keep track of attributes of the shell. */
  2125. #include <sys/types.h>
  2126. #include <termios.h>
  2127. #include <unistd.h>
  2128. pid_t shell_pgid;
  2129. struct termios shell_tmodes;
  2130. int shell_terminal;
  2131. int shell_is_interactive;
  2132. /* Make sure the shell is running interactively as the foreground job
  2133. before proceeding. */
  2134. void
  2135. init_shell ()
  2136. {
  2137. /* See if we are running interactively. */
  2138. shell_terminal = STDIN_FILENO;
  2139. shell_is_interactive = isatty (shell_terminal);
  2140. if (shell_is_interactive)
  2141. {
  2142. /* Loop until we are in the foreground. */
  2143. while (tcgetpgrp (shell_terminal) != (shell_pgid = getpgrp ()))
  2144. kill (- shell_pgid, SIGTTIN);
  2145. /* Ignore interactive and job-control signals. */
  2146. signal (SIGINT, SIG_IGN);
  2147. signal (SIGQUIT, SIG_IGN);
  2148. signal (SIGTSTP, SIG_IGN);
  2149. signal (SIGTTIN, SIG_IGN);
  2150. signal (SIGTTOU, SIG_IGN);
  2151. signal (SIGCHLD, SIG_IGN);
  2152. /* Put ourselves in our own process group. */
  2153. shell_pgid = getpid ();
  2154. if (setpgid (shell_pgid, shell_pgid) < 0)
  2155. {
  2156. perror ("Couldn't put the shell in its own process group");
  2157. exit (1);
  2158. }
  2159. /* Grab control of the terminal. */
  2160. tcsetpgrp (shell_terminal, shell_pgid);
  2161. /* Save default terminal attributes for shell. */
  2162. tcgetattr (shell_terminal, &shell_tmodes);
  2163. }
  2164. }
  2165. 
  2166. File: libc.info, Node: Launching Jobs, Next: Foreground and Background, Prev: Initializing the Shell, Up: Implementing a Shell
  2167. 28.6.3 Launching Jobs
  2168. ---------------------
  2169. Once the shell has taken responsibility for performing job control on
  2170. its controlling terminal, it can launch jobs in response to commands
  2171. typed by the user.
  2172. To create the processes in a process group, you use the same ‘fork’
  2173. and ‘exec’ functions described in *note Process Creation Concepts::.
  2174. Since there are multiple child processes involved, though, things are a
  2175. little more complicated and you must be careful to do things in the
  2176. right order. Otherwise, nasty race conditions can result.
  2177. You have two choices for how to structure the tree of parent-child
  2178. relationships among the processes. You can either make all the
  2179. processes in the process group be children of the shell process, or you
  2180. can make one process in group be the ancestor of all the other processes
  2181. in that group. The sample shell program presented in this chapter uses
  2182. the first approach because it makes bookkeeping somewhat simpler.
  2183. As each process is forked, it should put itself in the new process
  2184. group by calling ‘setpgid’; see *note Process Group Functions::. The
  2185. first process in the new group becomes its "process group leader", and
  2186. its process ID becomes the "process group ID" for the group.
  2187. The shell should also call ‘setpgid’ to put each of its child
  2188. processes into the new process group. This is because there is a
  2189. potential timing problem: each child process must be put in the process
  2190. group before it begins executing a new program, and the shell depends on
  2191. having all the child processes in the group before it continues
  2192. executing. If both the child processes and the shell call ‘setpgid’,
  2193. this ensures that the right things happen no matter which process gets
  2194. to it first.
  2195. If the job is being launched as a foreground job, the new process
  2196. group also needs to be put into the foreground on the controlling
  2197. terminal using ‘tcsetpgrp’. Again, this should be done by the shell as
  2198. well as by each of its child processes, to avoid race conditions.
  2199. The next thing each child process should do is to reset its signal
  2200. actions.
  2201. During initialization, the shell process set itself to ignore job
  2202. control signals; see *note Initializing the Shell::. As a result, any
  2203. child processes it creates also ignore these signals by inheritance.
  2204. This is definitely undesirable, so each child process should explicitly
  2205. set the actions for these signals back to ‘SIG_DFL’ just after it is
  2206. forked.
  2207. Since shells follow this convention, applications can assume that
  2208. they inherit the correct handling of these signals from the parent
  2209. process. But every application has a responsibility not to mess up the
  2210. handling of stop signals. Applications that disable the normal
  2211. interpretation of the SUSP character should provide some other mechanism
  2212. for the user to stop the job. When the user invokes this mechanism, the
  2213. program should send a ‘SIGTSTP’ signal to the process group of the
  2214. process, not just to the process itself. *Note Signaling Another
  2215. Process::.
  2216. Finally, each child process should call ‘exec’ in the normal way.
  2217. This is also the point at which redirection of the standard input and
  2218. output channels should be handled. *Note Duplicating Descriptors::, for
  2219. an explanation of how to do this.
  2220. Here is the function from the sample shell program that is
  2221. responsible for launching a program. The function is executed by each
  2222. child process immediately after it has been forked by the shell, and
  2223. never returns.
  2224. void
  2225. launch_process (process *p, pid_t pgid,
  2226. int infile, int outfile, int errfile,
  2227. int foreground)
  2228. {
  2229. pid_t pid;
  2230. if (shell_is_interactive)
  2231. {
  2232. /* Put the process into the process group and give the process group
  2233. the terminal, if appropriate.
  2234. This has to be done both by the shell and in the individual
  2235. child processes because of potential race conditions. */
  2236. pid = getpid ();
  2237. if (pgid == 0) pgid = pid;
  2238. setpgid (pid, pgid);
  2239. if (foreground)
  2240. tcsetpgrp (shell_terminal, pgid);
  2241. /* Set the handling for job control signals back to the default. */
  2242. signal (SIGINT, SIG_DFL);
  2243. signal (SIGQUIT, SIG_DFL);
  2244. signal (SIGTSTP, SIG_DFL);
  2245. signal (SIGTTIN, SIG_DFL);
  2246. signal (SIGTTOU, SIG_DFL);
  2247. signal (SIGCHLD, SIG_DFL);
  2248. }
  2249. /* Set the standard input/output channels of the new process. */
  2250. if (infile != STDIN_FILENO)
  2251. {
  2252. dup2 (infile, STDIN_FILENO);
  2253. close (infile);
  2254. }
  2255. if (outfile != STDOUT_FILENO)
  2256. {
  2257. dup2 (outfile, STDOUT_FILENO);
  2258. close (outfile);
  2259. }
  2260. if (errfile != STDERR_FILENO)
  2261. {
  2262. dup2 (errfile, STDERR_FILENO);
  2263. close (errfile);
  2264. }
  2265. /* Exec the new process. Make sure we exit. */
  2266. execvp (p->argv[0], p->argv);
  2267. perror ("execvp");
  2268. exit (1);
  2269. }
  2270. If the shell is not running interactively, this function does not do
  2271. anything with process groups or signals. Remember that a shell not
  2272. performing job control must keep all of its subprocesses in the same
  2273. process group as the shell itself.
  2274. Next, here is the function that actually launches a complete job.
  2275. After creating the child processes, this function calls some other
  2276. functions to put the newly created job into the foreground or
  2277. background; these are discussed in *note Foreground and Background::.
  2278. void
  2279. launch_job (job *j, int foreground)
  2280. {
  2281. process *p;
  2282. pid_t pid;
  2283. int mypipe[2], infile, outfile;
  2284. infile = j->stdin;
  2285. for (p = j->first_process; p; p = p->next)
  2286. {
  2287. /* Set up pipes, if necessary. */
  2288. if (p->next)
  2289. {
  2290. if (pipe (mypipe) < 0)
  2291. {
  2292. perror ("pipe");
  2293. exit (1);
  2294. }
  2295. outfile = mypipe[1];
  2296. }
  2297. else
  2298. outfile = j->stdout;
  2299. /* Fork the child processes. */
  2300. pid = fork ();
  2301. if (pid == 0)
  2302. /* This is the child process. */
  2303. launch_process (p, j->pgid, infile,
  2304. outfile, j->stderr, foreground);
  2305. else if (pid < 0)
  2306. {
  2307. /* The fork failed. */
  2308. perror ("fork");
  2309. exit (1);
  2310. }
  2311. else
  2312. {
  2313. /* This is the parent process. */
  2314. p->pid = pid;
  2315. if (shell_is_interactive)
  2316. {
  2317. if (!j->pgid)
  2318. j->pgid = pid;
  2319. setpgid (pid, j->pgid);
  2320. }
  2321. }
  2322. /* Clean up after pipes. */
  2323. if (infile != j->stdin)
  2324. close (infile);
  2325. if (outfile != j->stdout)
  2326. close (outfile);
  2327. infile = mypipe[0];
  2328. }
  2329. format_job_info (j, "launched");
  2330. if (!shell_is_interactive)
  2331. wait_for_job (j);
  2332. else if (foreground)
  2333. put_job_in_foreground (j, 0);
  2334. else
  2335. put_job_in_background (j, 0);
  2336. }
  2337. 
  2338. File: libc.info, Node: Foreground and Background, Next: Stopped and Terminated Jobs, Prev: Launching Jobs, Up: Implementing a Shell
  2339. 28.6.4 Foreground and Background
  2340. --------------------------------
  2341. Now let’s consider what actions must be taken by the shell when it
  2342. launches a job into the foreground, and how this differs from what must
  2343. be done when a background job is launched.
  2344. When a foreground job is launched, the shell must first give it
  2345. access to the controlling terminal by calling ‘tcsetpgrp’. Then, the
  2346. shell should wait for processes in that process group to terminate or
  2347. stop. This is discussed in more detail in *note Stopped and Terminated
  2348. Jobs::.
  2349. When all of the processes in the group have either completed or
  2350. stopped, the shell should regain control of the terminal for its own
  2351. process group by calling ‘tcsetpgrp’ again. Since stop signals caused
  2352. by I/O from a background process or a SUSP character typed by the user
  2353. are sent to the process group, normally all the processes in the job
  2354. stop together.
  2355. The foreground job may have left the terminal in a strange state, so
  2356. the shell should restore its own saved terminal modes before continuing.
  2357. In case the job is merely stopped, the shell should first save the
  2358. current terminal modes so that it can restore them later if the job is
  2359. continued. The functions for dealing with terminal modes are
  2360. ‘tcgetattr’ and ‘tcsetattr’; these are described in *note Terminal
  2361. Modes::.
  2362. Here is the sample shell’s function for doing all of this.
  2363. /* Put job J in the foreground. If CONT is nonzero,
  2364. restore the saved terminal modes and send the process group a
  2365. ‘SIGCONT’ signal to wake it up before we block. */
  2366. void
  2367. put_job_in_foreground (job *j, int cont)
  2368. {
  2369. /* Put the job into the foreground. */
  2370. tcsetpgrp (shell_terminal, j->pgid);
  2371. /* Send the job a continue signal, if necessary. */
  2372. if (cont)
  2373. {
  2374. tcsetattr (shell_terminal, TCSADRAIN, &j->tmodes);
  2375. if (kill (- j->pgid, SIGCONT) < 0)
  2376. perror ("kill (SIGCONT)");
  2377. }
  2378. /* Wait for it to report. */
  2379. wait_for_job (j);
  2380. /* Put the shell back in the foreground. */
  2381. tcsetpgrp (shell_terminal, shell_pgid);
  2382. /* Restore the shell’s terminal modes. */
  2383. tcgetattr (shell_terminal, &j->tmodes);
  2384. tcsetattr (shell_terminal, TCSADRAIN, &shell_tmodes);
  2385. }
  2386. If the process group is launched as a background job, the shell
  2387. should remain in the foreground itself and continue to read commands
  2388. from the terminal.
  2389. In the sample shell, there is not much that needs to be done to put a
  2390. job into the background. Here is the function it uses:
  2391. /* Put a job in the background. If the cont argument is true, send
  2392. the process group a ‘SIGCONT’ signal to wake it up. */
  2393. void
  2394. put_job_in_background (job *j, int cont)
  2395. {
  2396. /* Send the job a continue signal, if necessary. */
  2397. if (cont)
  2398. if (kill (-j->pgid, SIGCONT) < 0)
  2399. perror ("kill (SIGCONT)");
  2400. }
  2401. 
  2402. File: libc.info, Node: Stopped and Terminated Jobs, Next: Continuing Stopped Jobs, Prev: Foreground and Background, Up: Implementing a Shell
  2403. 28.6.5 Stopped and Terminated Jobs
  2404. ----------------------------------
  2405. When a foreground process is launched, the shell must block until all of
  2406. the processes in that job have either terminated or stopped. It can do
  2407. this by calling the ‘waitpid’ function; see *note Process Completion::.
  2408. Use the ‘WUNTRACED’ option so that status is reported for processes that
  2409. stop as well as processes that terminate.
  2410. The shell must also check on the status of background jobs so that it
  2411. can report terminated and stopped jobs to the user; this can be done by
  2412. calling ‘waitpid’ with the ‘WNOHANG’ option. A good place to put a such
  2413. a check for terminated and stopped jobs is just before prompting for a
  2414. new command.
  2415. The shell can also receive asynchronous notification that there is
  2416. status information available for a child process by establishing a
  2417. handler for ‘SIGCHLD’ signals. *Note Signal Handling::.
  2418. In the sample shell program, the ‘SIGCHLD’ signal is normally
  2419. ignored. This is to avoid reentrancy problems involving the global data
  2420. structures the shell manipulates. But at specific times when the shell
  2421. is not using these data structures—such as when it is waiting for input
  2422. on the terminal—it makes sense to enable a handler for ‘SIGCHLD’. The
  2423. same function that is used to do the synchronous status checks
  2424. (‘do_job_notification’, in this case) can also be called from within
  2425. this handler.
  2426. Here are the parts of the sample shell program that deal with
  2427. checking the status of jobs and reporting the information to the user.
  2428. /* Store the status of the process PID that was returned by waitpid.
  2429. Return 0 if all went well, nonzero otherwise. */
  2430. int
  2431. mark_process_status (pid_t pid, int status)
  2432. {
  2433. job *j;
  2434. process *p;
  2435. if (pid > 0)
  2436. {
  2437. /* Update the record for the process. */
  2438. for (j = first_job; j; j = j->next)
  2439. for (p = j->first_process; p; p = p->next)
  2440. if (p->pid == pid)
  2441. {
  2442. p->status = status;
  2443. if (WIFSTOPPED (status))
  2444. p->stopped = 1;
  2445. else
  2446. {
  2447. p->completed = 1;
  2448. if (WIFSIGNALED (status))
  2449. fprintf (stderr, "%d: Terminated by signal %d.\n",
  2450. (int) pid, WTERMSIG (p->status));
  2451. }
  2452. return 0;
  2453. }
  2454. fprintf (stderr, "No child process %d.\n", pid);
  2455. return -1;
  2456. }
  2457. else if (pid == 0 || errno == ECHILD)
  2458. /* No processes ready to report. */
  2459. return -1;
  2460. else {
  2461. /* Other weird errors. */
  2462. perror ("waitpid");
  2463. return -1;
  2464. }
  2465. }
  2466. /* Check for processes that have status information available,
  2467. without blocking. */
  2468. void
  2469. update_status (void)
  2470. {
  2471. int status;
  2472. pid_t pid;
  2473. do
  2474. pid = waitpid (WAIT_ANY, &status, WUNTRACED|WNOHANG);
  2475. while (!mark_process_status (pid, status));
  2476. }
  2477. /* Check for processes that have status information available,
  2478. blocking until all processes in the given job have reported. */
  2479. void
  2480. wait_for_job (job *j)
  2481. {
  2482. int status;
  2483. pid_t pid;
  2484. do
  2485. pid = waitpid (WAIT_ANY, &status, WUNTRACED);
  2486. while (!mark_process_status (pid, status)
  2487. && !job_is_stopped (j)
  2488. && !job_is_completed (j));
  2489. }
  2490. /* Format information about job status for the user to look at. */
  2491. void
  2492. format_job_info (job *j, const char *status)
  2493. {
  2494. fprintf (stderr, "%ld (%s): %s\n", (long)j->pgid, status, j->command);
  2495. }
  2496. /* Notify the user about stopped or terminated jobs.
  2497. Delete terminated jobs from the active job list. */
  2498. void
  2499. do_job_notification (void)
  2500. {
  2501. job *j, *jlast, *jnext;
  2502. process *p;
  2503. /* Update status information for child processes. */
  2504. update_status ();
  2505. jlast = NULL;
  2506. for (j = first_job; j; j = jnext)
  2507. {
  2508. jnext = j->next;
  2509. /* If all processes have completed, tell the user the job has
  2510. completed and delete it from the list of active jobs. */
  2511. if (job_is_completed (j)) {
  2512. format_job_info (j, "completed");
  2513. if (jlast)
  2514. jlast->next = jnext;
  2515. else
  2516. first_job = jnext;
  2517. free_job (j);
  2518. }
  2519. /* Notify the user about stopped jobs,
  2520. marking them so that we won’t do this more than once. */
  2521. else if (job_is_stopped (j) && !j->notified) {
  2522. format_job_info (j, "stopped");
  2523. j->notified = 1;
  2524. jlast = j;
  2525. }
  2526. /* Don’t say anything about jobs that are still running. */
  2527. else
  2528. jlast = j;
  2529. }
  2530. }
  2531. 
  2532. File: libc.info, Node: Continuing Stopped Jobs, Next: Missing Pieces, Prev: Stopped and Terminated Jobs, Up: Implementing a Shell
  2533. 28.6.6 Continuing Stopped Jobs
  2534. ------------------------------
  2535. The shell can continue a stopped job by sending a ‘SIGCONT’ signal to
  2536. its process group. If the job is being continued in the foreground, the
  2537. shell should first invoke ‘tcsetpgrp’ to give the job access to the
  2538. terminal, and restore the saved terminal settings. After continuing a
  2539. job in the foreground, the shell should wait for the job to stop or
  2540. complete, as if the job had just been launched in the foreground.
  2541. The sample shell program handles both newly created and continued
  2542. jobs with the same pair of functions, ‘put_job_in_foreground’ and
  2543. ‘put_job_in_background’. The definitions of these functions were given
  2544. in *note Foreground and Background::. When continuing a stopped job, a
  2545. nonzero value is passed as the CONT argument to ensure that the
  2546. ‘SIGCONT’ signal is sent and the terminal modes reset, as appropriate.
  2547. This leaves only a function for updating the shell’s internal
  2548. bookkeeping about the job being continued:
  2549. /* Mark a stopped job J as being running again. */
  2550. void
  2551. mark_job_as_running (job *j)
  2552. {
  2553. Process *p;
  2554. for (p = j->first_process; p; p = p->next)
  2555. p->stopped = 0;
  2556. j->notified = 0;
  2557. }
  2558. /* Continue the job J. */
  2559. void
  2560. continue_job (job *j, int foreground)
  2561. {
  2562. mark_job_as_running (j);
  2563. if (foreground)
  2564. put_job_in_foreground (j, 1);
  2565. else
  2566. put_job_in_background (j, 1);
  2567. }
  2568. 
  2569. File: libc.info, Node: Missing Pieces, Prev: Continuing Stopped Jobs, Up: Implementing a Shell
  2570. 28.6.7 The Missing Pieces
  2571. -------------------------
  2572. The code extracts for the sample shell included in this chapter are only
  2573. a part of the entire shell program. In particular, nothing at all has
  2574. been said about how ‘job’ and ‘program’ data structures are allocated
  2575. and initialized.
  2576. Most real shells provide a complex user interface that has support
  2577. for a command language; variables; abbreviations, substitutions, and
  2578. pattern matching on file names; and the like. All of this is far too
  2579. complicated to explain here! Instead, we have concentrated on showing
  2580. how to implement the core process creation and job control functions
  2581. that can be called from such a shell.
  2582. Here is a table summarizing the major entry points we have presented:
  2583. ‘void init_shell (void)’
  2584. Initialize the shell’s internal state. *Note Initializing the
  2585. Shell::.
  2586. ‘void launch_job (job *J, int FOREGROUND)’
  2587. Launch the job J as either a foreground or background job. *Note
  2588. Launching Jobs::.
  2589. ‘void do_job_notification (void)’
  2590. Check for and report any jobs that have terminated or stopped. Can
  2591. be called synchronously or within a handler for ‘SIGCHLD’ signals.
  2592. *Note Stopped and Terminated Jobs::.
  2593. ‘void continue_job (job *J, int FOREGROUND)’
  2594. Continue the job J. *Note Continuing Stopped Jobs::.
  2595. Of course, a real shell would also want to provide other functions
  2596. for managing jobs. For example, it would be useful to have commands to
  2597. list all active jobs or to send a signal (such as ‘SIGKILL’) to a job.
  2598. 
  2599. File: libc.info, Node: Functions for Job Control, Prev: Implementing a Shell, Up: Job Control
  2600. 28.7 Functions for Job Control
  2601. ==============================
  2602. This section contains detailed descriptions of the functions relating to
  2603. job control.
  2604. * Menu:
  2605. * Identifying the Terminal:: Determining the controlling terminal’s name.
  2606. * Process Group Functions:: Functions for manipulating process groups.
  2607. * Terminal Access Functions:: Functions for controlling terminal access.
  2608. 
  2609. File: libc.info, Node: Identifying the Terminal, Next: Process Group Functions, Up: Functions for Job Control
  2610. 28.7.1 Identifying the Controlling Terminal
  2611. -------------------------------------------
  2612. You can use the ‘ctermid’ function to get a file name that you can use
  2613. to open the controlling terminal. In the GNU C Library, it returns the
  2614. same string all the time: ‘"/dev/tty"’. That is a special “magic” file
  2615. name that refers to the controlling terminal of the current process (if
  2616. it has one). To find the name of the specific terminal device, use
  2617. ‘ttyname’; *note Is It a Terminal::.
  2618. The function ‘ctermid’ is declared in the header file ‘stdio.h’.
  2619. -- Function: char * ctermid (char *STRING)
  2620. Preliminary: | MT-Safe !posix/!string | AS-Safe | AC-Safe | *Note
  2621. POSIX Safety Concepts::.
  2622. The ‘ctermid’ function returns a string containing the file name of
  2623. the controlling terminal for the current process. If STRING is not
  2624. a null pointer, it should be an array that can hold at least
  2625. ‘L_ctermid’ characters; the string is returned in this array.
  2626. Otherwise, a pointer to a string in a static area is returned,
  2627. which might get overwritten on subsequent calls to this function.
  2628. An empty string is returned if the file name cannot be determined
  2629. for any reason. Even if a file name is returned, access to the
  2630. file it represents is not guaranteed.
  2631. -- Macro: int L_ctermid
  2632. The value of this macro is an integer constant expression that
  2633. represents the size of a string large enough to hold the file name
  2634. returned by ‘ctermid’.
  2635. See also the ‘isatty’ and ‘ttyname’ functions, in *note Is It a
  2636. Terminal::.
  2637. 
  2638. File: libc.info, Node: Process Group Functions, Next: Terminal Access Functions, Prev: Identifying the Terminal, Up: Functions for Job Control
  2639. 28.7.2 Process Group Functions
  2640. ------------------------------
  2641. Here are descriptions of the functions for manipulating process groups.
  2642. Your program should include the header files ‘sys/types.h’ and
  2643. ‘unistd.h’ to use these functions.
  2644. -- Function: pid_t setsid (void)
  2645. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2646. Concepts::.
  2647. The ‘setsid’ function creates a new session. The calling process
  2648. becomes the session leader, and is put in a new process group whose
  2649. process group ID is the same as the process ID of that process.
  2650. There are initially no other processes in the new process group,
  2651. and no other process groups in the new session.
  2652. This function also makes the calling process have no controlling
  2653. terminal.
  2654. The ‘setsid’ function returns the new process group ID of the
  2655. calling process if successful. A return value of ‘-1’ indicates an
  2656. error. The following ‘errno’ error conditions are defined for this
  2657. function:
  2658. ‘EPERM’
  2659. The calling process is already a process group leader, or
  2660. there is already another process group around that has the
  2661. same process group ID.
  2662. -- Function: pid_t getsid (pid_t PID)
  2663. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2664. Concepts::.
  2665. The ‘getsid’ function returns the process group ID of the session
  2666. leader of the specified process. If a PID is ‘0’, the process
  2667. group ID of the session leader of the current process is returned.
  2668. In case of error ‘-1’ is returned and ‘errno’ is set. The
  2669. following ‘errno’ error conditions are defined for this function:
  2670. ‘ESRCH’
  2671. There is no process with the given process ID PID.
  2672. ‘EPERM’
  2673. The calling process and the process specified by PID are in
  2674. different sessions, and the implementation doesn’t allow to
  2675. access the process group ID of the session leader of the
  2676. process with ID PID from the calling process.
  2677. -- Function: pid_t getpgrp (void)
  2678. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2679. Concepts::.
  2680. The ‘getpgrp’ function returns the process group ID of the calling
  2681. process.
  2682. -- Function: int getpgid (pid_t PID)
  2683. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2684. Concepts::.
  2685. The ‘getpgid’ function returns the process group ID of the process
  2686. PID. You can supply a value of ‘0’ for the PID argument to get
  2687. information about the calling process.
  2688. In case of error ‘-1’ is returned and ‘errno’ is set. The
  2689. following ‘errno’ error conditions are defined for this function:
  2690. ‘ESRCH’
  2691. There is no process with the given process ID PID. The
  2692. calling process and the process specified by PID are in
  2693. different sessions, and the implementation doesn’t allow to
  2694. access the process group ID of the process with ID PID from
  2695. the calling process.
  2696. -- Function: int setpgid (pid_t PID, pid_t PGID)
  2697. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2698. Concepts::.
  2699. The ‘setpgid’ function puts the process PID into the process group
  2700. PGID. As a special case, either PID or PGID can be zero to
  2701. indicate the process ID of the calling process.
  2702. This function fails on a system that does not support job control.
  2703. *Note Job Control is Optional::, for more information.
  2704. If the operation is successful, ‘setpgid’ returns zero. Otherwise
  2705. it returns ‘-1’. The following ‘errno’ error conditions are
  2706. defined for this function:
  2707. ‘EACCES’
  2708. The child process named by PID has executed an ‘exec’ function
  2709. since it was forked.
  2710. ‘EINVAL’
  2711. The value of the PGID is not valid.
  2712. ‘ENOSYS’
  2713. The system doesn’t support job control.
  2714. ‘EPERM’
  2715. The process indicated by the PID argument is a session leader,
  2716. or is not in the same session as the calling process, or the
  2717. value of the PGID argument doesn’t match a process group ID in
  2718. the same session as the calling process.
  2719. ‘ESRCH’
  2720. The process indicated by the PID argument is not the calling
  2721. process or a child of the calling process.
  2722. -- Function: int setpgrp (pid_t PID, pid_t PGID)
  2723. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2724. Concepts::.
  2725. This is the BSD Unix name for ‘setpgid’. Both functions do exactly
  2726. the same thing.
  2727. 
  2728. File: libc.info, Node: Terminal Access Functions, Prev: Process Group Functions, Up: Functions for Job Control
  2729. 28.7.3 Functions for Controlling Terminal Access
  2730. ------------------------------------------------
  2731. These are the functions for reading or setting the foreground process
  2732. group of a terminal. You should include the header files ‘sys/types.h’
  2733. and ‘unistd.h’ in your application to use these functions.
  2734. Although these functions take a file descriptor argument to specify
  2735. the terminal device, the foreground job is associated with the terminal
  2736. file itself and not a particular open file descriptor.
  2737. -- Function: pid_t tcgetpgrp (int FILEDES)
  2738. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2739. Concepts::.
  2740. This function returns the process group ID of the foreground
  2741. process group associated with the terminal open on descriptor
  2742. FILEDES.
  2743. If there is no foreground process group, the return value is a
  2744. number greater than ‘1’ that does not match the process group ID of
  2745. any existing process group. This can happen if all of the
  2746. processes in the job that was formerly the foreground job have
  2747. terminated, and no other job has yet been moved into the
  2748. foreground.
  2749. In case of an error, a value of ‘-1’ is returned. The following
  2750. ‘errno’ error conditions are defined for this function:
  2751. ‘EBADF’
  2752. The FILEDES argument is not a valid file descriptor.
  2753. ‘ENOSYS’
  2754. The system doesn’t support job control.
  2755. ‘ENOTTY’
  2756. The terminal file associated with the FILEDES argument isn’t
  2757. the controlling terminal of the calling process.
  2758. -- Function: int tcsetpgrp (int FILEDES, pid_t PGID)
  2759. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2760. Concepts::.
  2761. This function is used to set a terminal’s foreground process group
  2762. ID. The argument FILEDES is a descriptor which specifies the
  2763. terminal; PGID specifies the process group. The calling process
  2764. must be a member of the same session as PGID and must have the same
  2765. controlling terminal.
  2766. For terminal access purposes, this function is treated as output.
  2767. If it is called from a background process on its controlling
  2768. terminal, normally all processes in the process group are sent a
  2769. ‘SIGTTOU’ signal. The exception is if the calling process itself
  2770. is ignoring or blocking ‘SIGTTOU’ signals, in which case the
  2771. operation is performed and no signal is sent.
  2772. If successful, ‘tcsetpgrp’ returns ‘0’. A return value of ‘-1’
  2773. indicates an error. The following ‘errno’ error conditions are
  2774. defined for this function:
  2775. ‘EBADF’
  2776. The FILEDES argument is not a valid file descriptor.
  2777. ‘EINVAL’
  2778. The PGID argument is not valid.
  2779. ‘ENOSYS’
  2780. The system doesn’t support job control.
  2781. ‘ENOTTY’
  2782. The FILEDES isn’t the controlling terminal of the calling
  2783. process.
  2784. ‘EPERM’
  2785. The PGID isn’t a process group in the same session as the
  2786. calling process.
  2787. -- Function: pid_t tcgetsid (int FILDES)
  2788. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  2789. Concepts::.
  2790. This function is used to obtain the process group ID of the session
  2791. for which the terminal specified by FILDES is the controlling
  2792. terminal. If the call is successful the group ID is returned.
  2793. Otherwise the return value is ‘(pid_t) -1’ and the global variable
  2794. ERRNO is set to the following value:
  2795. ‘EBADF’
  2796. The FILEDES argument is not a valid file descriptor.
  2797. ‘ENOTTY’
  2798. The calling process does not have a controlling terminal, or
  2799. the file is not the controlling terminal.
  2800. 
  2801. File: libc.info, Node: Name Service Switch, Next: Users and Groups, Prev: Job Control, Up: Top
  2802. 29 System Databases and Name Service Switch
  2803. *******************************************
  2804. Various functions in the C Library need to be configured to work
  2805. correctly in the local environment. Traditionally, this was done by
  2806. using files (e.g., ‘/etc/passwd’), but other nameservices (like the
  2807. Network Information Service (NIS) and the Domain Name Service (DNS))
  2808. became popular, and were hacked into the C library, usually with a fixed
  2809. search order.
  2810. The GNU C Library contains a cleaner solution to this problem. It is
  2811. designed after a method used by Sun Microsystems in the C library of
  2812. Solaris 2. The GNU C Library follows their name and calls this scheme
  2813. "Name Service Switch" (NSS).
  2814. Though the interface might be similar to Sun’s version there is no
  2815. common code. We never saw any source code of Sun’s implementation and
  2816. so the internal interface is incompatible. This also manifests in the
  2817. file names we use as we will see later.
  2818. * Menu:
  2819. * NSS Basics:: What is this NSS good for.
  2820. * NSS Configuration File:: Configuring NSS.
  2821. * NSS Module Internals:: How does it work internally.
  2822. * Extending NSS:: What to do to add services or databases.
  2823. 
  2824. File: libc.info, Node: NSS Basics, Next: NSS Configuration File, Prev: Name Service Switch, Up: Name Service Switch
  2825. 29.1 NSS Basics
  2826. ===============
  2827. The basic idea is to put the implementation of the different services
  2828. offered to access the databases in separate modules. This has some
  2829. advantages:
  2830. 1. Contributors can add new services without adding them to the GNU C
  2831. Library.
  2832. 2. The modules can be updated separately.
  2833. 3. The C library image is smaller.
  2834. To fulfill the first goal above, the ABI of the modules will be
  2835. described below. For getting the implementation of a new service right
  2836. it is important to understand how the functions in the modules get
  2837. called. They are in no way designed to be used by the programmer
  2838. directly. Instead the programmer should only use the documented and
  2839. standardized functions to access the databases.
  2840. The databases available in the NSS are
  2841. ‘aliases’
  2842. Mail aliases
  2843. ‘ethers’
  2844. Ethernet numbers,
  2845. ‘group’
  2846. Groups of users, *note Group Database::.
  2847. ‘hosts’
  2848. Host names and numbers, *note Host Names::.
  2849. ‘netgroup’
  2850. Network wide list of host and users, *note Netgroup Database::.
  2851. ‘networks’
  2852. Network names and numbers, *note Networks Database::.
  2853. ‘protocols’
  2854. Network protocols, *note Protocols Database::.
  2855. ‘passwd’
  2856. User passwords, *note User Database::.
  2857. ‘rpc’
  2858. Remote procedure call names and numbers,
  2859. ‘services’
  2860. Network services, *note Services Database::.
  2861. ‘shadow’
  2862. Shadow user passwords,
  2863. There will be some more added later (‘automount’, ‘bootparams’,
  2864. ‘netmasks’, and ‘publickey’).
  2865. 
  2866. File: libc.info, Node: NSS Configuration File, Next: NSS Module Internals, Prev: NSS Basics, Up: Name Service Switch
  2867. 29.2 The NSS Configuration File
  2868. ===============================
  2869. Somehow the NSS code must be told about the wishes of the user. For
  2870. this reason there is the file ‘/etc/nsswitch.conf’. For each database,
  2871. this file contains a specification of how the lookup process should
  2872. work. The file could look like this:
  2873. # /etc/nsswitch.conf
  2874. #
  2875. # Name Service Switch configuration file.
  2876. #
  2877. passwd: db files nis
  2878. shadow: files
  2879. group: db files nis
  2880. hosts: files nisplus nis dns
  2881. networks: nisplus [NOTFOUND=return] files
  2882. ethers: nisplus [NOTFOUND=return] db files
  2883. protocols: nisplus [NOTFOUND=return] db files
  2884. rpc: nisplus [NOTFOUND=return] db files
  2885. services: nisplus [NOTFOUND=return] db files
  2886. The first column is the database as you can guess from the table
  2887. above. The rest of the line specifies how the lookup process works.
  2888. Please note that you specify the way it works for each database
  2889. individually. This cannot be done with the old way of a monolithic
  2890. implementation.
  2891. The configuration specification for each database can contain two
  2892. different items:
  2893. • the service specification like ‘files’, ‘db’, or ‘nis’.
  2894. • the reaction on lookup result like ‘[NOTFOUND=return]’.
  2895. * Menu:
  2896. * Services in the NSS configuration:: Service names in the NSS configuration.
  2897. * Actions in the NSS configuration:: React appropriately to the lookup result.
  2898. * Notes on NSS Configuration File:: Things to take care about while
  2899. configuring NSS.
  2900. 
  2901. File: libc.info, Node: Services in the NSS configuration, Next: Actions in the NSS configuration, Prev: NSS Configuration File, Up: NSS Configuration File
  2902. 29.2.1 Services in the NSS configuration File
  2903. ---------------------------------------------
  2904. The above example file mentions five different services: ‘files’, ‘db’,
  2905. ‘dns’, ‘nis’, and ‘nisplus’. This does not mean these services are
  2906. available on all sites and neither does it mean these are all the
  2907. services which will ever be available.
  2908. In fact, these names are simply strings which the NSS code uses to
  2909. find the implicitly addressed functions. The internal interface will be
  2910. described later. Visible to the user are the modules which implement an
  2911. individual service.
  2912. Assume the service NAME shall be used for a lookup. The code for
  2913. this service is implemented in a module called ‘libnss_NAME’. On a
  2914. system supporting shared libraries this is in fact a shared library with
  2915. the name (for example) ‘libnss_NAME.so.2’. The number at the end is the
  2916. currently used version of the interface which will not change
  2917. frequently. Normally the user should not have to be cognizant of these
  2918. files since they should be placed in a directory where they are found
  2919. automatically. Only the names of all available services are important.
  2920. 
  2921. 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
  2922. 29.2.2 Actions in the NSS configuration
  2923. ---------------------------------------
  2924. The second item in the specification gives the user much finer control
  2925. on the lookup process. Action items are placed between two service
  2926. names and are written within brackets. The general form is
  2927. ‘[’ ( ‘!’? STATUS ‘=’ ACTION )+ ‘]’
  2928. where
  2929. STATUS ⇒ success | notfound | unavail | tryagain
  2930. ACTION ⇒ return | continue
  2931. The case of the keywords is insignificant. The STATUS values are the
  2932. results of a call to a lookup function of a specific service. They
  2933. mean:
  2934. ‘success’
  2935. No error occurred and the wanted entry is returned. The default
  2936. action for this is ‘return’.
  2937. ‘notfound’
  2938. The lookup process works ok but the needed value was not found.
  2939. The default action is ‘continue’.
  2940. ‘unavail’
  2941. The service is permanently unavailable. This can either mean the
  2942. needed file is not available, or, for DNS, the server is not
  2943. available or does not allow queries. The default action is
  2944. ‘continue’.
  2945. ‘tryagain’
  2946. The service is temporarily unavailable. This could mean a file is
  2947. locked or a server currently cannot accept more connections. The
  2948. default action is ‘continue’.
  2949. The ACTION values mean:
  2950. ‘return’
  2951. If the status matches, stop the lookup process at this service
  2952. specification. If an entry is available, provide it to the
  2953. application. If an error occurred, report it to the application.
  2954. In case of a prior ‘merge’ action, the data is combined with
  2955. previous lookup results, as explained below.
  2956. ‘continue’
  2957. If the status matches, proceed with the lookup process at the next
  2958. entry, discarding the result of the current lookup (and any merged
  2959. data). An exception is the ‘initgroups’ database and the ‘success’
  2960. status, where ‘continue’ acts like ‘merge’ below.
  2961. ‘merge’
  2962. Proceed with the lookup process, retaining the current lookup
  2963. result. This action is useful only with the ‘success’ status. If
  2964. a subsequent service lookup succeeds and has a matching ‘return’
  2965. specification, the results are merged, the lookup process ends, and
  2966. the merged results are returned to the application. If the
  2967. following service has a matching ‘merge’ action, the lookup process
  2968. continues, retaining the combined data from this and any previous
  2969. lookups.
  2970. After a ‘merge’ action, errors from subsequent lookups are ignored,
  2971. and the data gathered so far will be returned.
  2972. The ‘merge’ only applies to the ‘success’ status. It is currently
  2973. implemented for the ‘group’ database and its group members field,
  2974. ‘gr_mem’. If specified for other databases, it causes the lookup
  2975. to fail (if the STATUS matches).
  2976. When processing ‘merge’ for ‘group’ membership, the group GID and
  2977. name must be identical for both entries. If only one or the other
  2978. is a match, the behavior is undefined.
  2979. If we have a line like
  2980. ethers: nisplus [NOTFOUND=return] db files
  2981. this is equivalent to
  2982. ethers: nisplus [SUCCESS=return NOTFOUND=return UNAVAIL=continue
  2983. TRYAGAIN=continue]
  2984. db [SUCCESS=return NOTFOUND=continue UNAVAIL=continue
  2985. TRYAGAIN=continue]
  2986. files
  2987. (except that it would have to be written on one line). The default
  2988. value for the actions are normally what you want, and only need to be
  2989. changed in exceptional cases.
  2990. If the optional ‘!’ is placed before the STATUS this means the
  2991. following action is used for all statuses but STATUS itself. I.e., ‘!’
  2992. is negation as in the C language (and others).
  2993. Before we explain the exception which makes this action item
  2994. necessary one more remark: obviously it makes no sense to add another
  2995. action item after the ‘files’ service. Since there is no other service
  2996. following the action _always_ is ‘return’.
  2997. Now, why is this ‘[NOTFOUND=return]’ action useful? To understand
  2998. this we should know that the ‘nisplus’ service is often complete; i.e.,
  2999. if an entry is not available in the NIS+ tables it is not available
  3000. anywhere else. This is what is expressed by this action item: it is
  3001. useless to examine further services since they will not give us a
  3002. result.
  3003. The situation would be different if the NIS+ service is not available
  3004. because the machine is booting. In this case the return value of the
  3005. lookup function is not ‘notfound’ but instead ‘unavail’. And as you can
  3006. see in the complete form above: in this situation the ‘db’ and ‘files’
  3007. services are used. Neat, isn’t it? The system administrator need not
  3008. pay special care for the time the system is not completely ready to work
  3009. (while booting or shutdown or network problems).
  3010. 
  3011. File: libc.info, Node: Notes on NSS Configuration File, Prev: Actions in the NSS configuration, Up: NSS Configuration File
  3012. 29.2.3 Notes on the NSS Configuration File
  3013. ------------------------------------------
  3014. Finally a few more hints. The NSS implementation is not completely
  3015. helpless if ‘/etc/nsswitch.conf’ does not exist. For all supported
  3016. databases there is a default value so it should normally be possible to
  3017. get the system running even if the file is corrupted or missing.
  3018. For the ‘hosts’ and ‘networks’ databases the default value is ‘dns
  3019. [!UNAVAIL=return] files’. I.e., the system is prepared for the DNS
  3020. service not to be available but if it is available the answer it returns
  3021. is definitive.
  3022. The ‘passwd’, ‘group’, and ‘shadow’ databases are traditionally
  3023. handled in a special way. The appropriate files in the ‘/etc’ directory
  3024. are read but if an entry with a name starting with a ‘+’ character is
  3025. found NIS is used. This kind of lookup remains possible by using the
  3026. special lookup service ‘compat’ and the default value for the three
  3027. databases above is ‘compat [NOTFOUND=return] files’.
  3028. For all other databases the default value is ‘nis [NOTFOUND=return]
  3029. files’. This solution gives the best chance to be correct since NIS and
  3030. file based lookups are used.
  3031. A second point is that the user should try to optimize the lookup
  3032. process. The different service have different response times. A simple
  3033. file look up on a local file could be fast, but if the file is long and
  3034. the needed entry is near the end of the file this may take quite some
  3035. time. In this case it might be better to use the ‘db’ service which
  3036. allows fast local access to large data sets.
  3037. Often the situation is that some global information like NIS must be
  3038. used. So it is unavoidable to use service entries like ‘nis’ etc. But
  3039. one should avoid slow services like this if possible.
  3040. 
  3041. File: libc.info, Node: NSS Module Internals, Next: Extending NSS, Prev: NSS Configuration File, Up: Name Service Switch
  3042. 29.3 NSS Module Internals
  3043. =========================
  3044. Now it is time to describe what the modules look like. The functions
  3045. contained in a module are identified by their names. I.e., there is no
  3046. jump table or the like. How this is done is of no interest here; those
  3047. interested in this topic should read about Dynamic Linking.
  3048. * Menu:
  3049. * NSS Module Names:: Construction of the interface function of
  3050. the NSS modules.
  3051. * NSS Modules Interface:: Programming interface in the NSS module
  3052. functions.
  3053. 
  3054. File: libc.info, Node: NSS Module Names, Next: NSS Modules Interface, Prev: NSS Module Internals, Up: NSS Module Internals
  3055. 29.3.1 The Naming Scheme of the NSS Modules
  3056. -------------------------------------------
  3057. The name of each function consists of various parts:
  3058. _nss_SERVICE_FUNCTION
  3059. SERVICE of course corresponds to the name of the module this function
  3060. is found in.(1) The FUNCTION part is derived from the interface
  3061. function in the C library itself. If the user calls the function
  3062. ‘gethostbyname’ and the service used is ‘files’ the function
  3063. _nss_files_gethostbyname_r
  3064. in the module
  3065. libnss_files.so.2
  3066. is used. You see, what is explained above in not the whole truth. In
  3067. fact the NSS modules only contain reentrant versions of the lookup
  3068. functions. I.e., if the user would call the ‘gethostbyname_r’ function
  3069. this also would end in the above function. For all user interface
  3070. functions the C library maps this call to a call to the reentrant
  3071. function. For reentrant functions this is trivial since the interface
  3072. is (nearly) the same. For the non-reentrant version the library keeps
  3073. internal buffers which are used to replace the user supplied buffer.
  3074. I.e., the reentrant functions _can_ have counterparts. No service
  3075. module is forced to have functions for all databases and all kinds to
  3076. access them. If a function is not available it is simply treated as if
  3077. the function would return ‘unavail’ (*note Actions in the NSS
  3078. configuration::).
  3079. The file name ‘libnss_files.so.2’ would be on a Solaris 2 system
  3080. ‘nss_files.so.2’. This is the difference mentioned above. Sun’s NSS
  3081. modules are usable as modules which get indirectly loaded only.
  3082. The NSS modules in the GNU C Library are prepared to be used as
  3083. normal libraries themselves. This is _not_ true at the moment, though.
  3084. However, the organization of the name space in the modules does not make
  3085. it impossible like it is for Solaris. Now you can see why the modules
  3086. are still libraries.(2)
  3087. ---------- Footnotes ----------
  3088. (1) Now you might ask why this information is duplicated. The answer
  3089. is that we want to make it possible to link directly with these shared
  3090. objects.
  3091. (2) There is a second explanation: we were too lazy to change the
  3092. Makefiles to allow the generation of shared objects not starting with
  3093. ‘lib’ but don’t tell this to anybody.
  3094. 
  3095. File: libc.info, Node: NSS Modules Interface, Prev: NSS Module Names, Up: NSS Module Internals
  3096. 29.3.2 The Interface of the Function in NSS Modules
  3097. ---------------------------------------------------
  3098. Now we know about the functions contained in the modules. It is now
  3099. time to describe the types. When we mentioned the reentrant versions of
  3100. the functions above, this means there are some additional arguments
  3101. (compared with the standard, non-reentrant versions). The prototypes
  3102. for the non-reentrant and reentrant versions of our function above are:
  3103. struct hostent *gethostbyname (const char *name)
  3104. int gethostbyname_r (const char *name, struct hostent *result_buf,
  3105. char *buf, size_t buflen, struct hostent **result,
  3106. int *h_errnop)
  3107. The actual prototype of the function in the NSS modules in this case is
  3108. enum nss_status _nss_files_gethostbyname_r (const char *name,
  3109. struct hostent *result_buf,
  3110. char *buf, size_t buflen,
  3111. int *errnop, int *h_errnop)
  3112. I.e., the interface function is in fact the reentrant function with
  3113. the change of the return value, the omission of the RESULT parameter,
  3114. and the addition of the ERRNOP parameter. While the user-level function
  3115. returns a pointer to the result the reentrant function return an ‘enum
  3116. nss_status’ value:
  3117. ‘NSS_STATUS_TRYAGAIN’
  3118. numeric value ‘-2’
  3119. ‘NSS_STATUS_UNAVAIL’
  3120. numeric value ‘-1’
  3121. ‘NSS_STATUS_NOTFOUND’
  3122. numeric value ‘0’
  3123. ‘NSS_STATUS_SUCCESS’
  3124. numeric value ‘1’
  3125. Now you see where the action items of the ‘/etc/nsswitch.conf’ file are
  3126. used.
  3127. If you study the source code you will find there is a fifth value:
  3128. ‘NSS_STATUS_RETURN’. This is an internal use only value, used by a few
  3129. functions in places where none of the above value can be used. If
  3130. necessary the source code should be examined to learn about the details.
  3131. In case the interface function has to return an error it is important
  3132. that the correct error code is stored in ‘*ERRNOP’. Some return status
  3133. values have only one associated error code, others have more.
  3134. ‘NSS_STATUS_TRYAGAIN’ ‘EAGAIN’ One of the functions used ran
  3135. temporarily out of resources or a
  3136. service is currently not
  3137. available.
  3138. ‘ERANGE’ The provided buffer is not large
  3139. enough. The function should be
  3140. called again with a larger buffer.
  3141. ‘NSS_STATUS_UNAVAIL’ ‘ENOENT’ A necessary input file cannot be
  3142. found.
  3143. ‘NSS_STATUS_NOTFOUND’ ‘ENOENT’ The requested entry is not
  3144. available.
  3145. ‘NSS_STATUS_NOTFOUND’ ‘SUCCESS’ There are no entries. Use this to
  3146. avoid returning errors for
  3147. inactive services which may be
  3148. enabled at a later time. This is
  3149. not the same as the service being
  3150. temporarily unavailable.
  3151. These are proposed values. There can be other error codes and the
  3152. described error codes can have different meaning. *With one exception:*
  3153. when returning ‘NSS_STATUS_TRYAGAIN’ the error code ‘ERANGE’ _must_ mean
  3154. that the user provided buffer is too small. Everything else is
  3155. non-critical.
  3156. In statically linked programs, the main application and NSS modules
  3157. do not share the same thread-local variable ‘errno’, which is the reason
  3158. why there is an explicit ERRNOP function argument.
  3159. The above function has something special which is missing for almost
  3160. all the other module functions. There is an argument H_ERRNOP. This
  3161. points to a variable which will be filled with the error code in case
  3162. the execution of the function fails for some reason. (In statically
  3163. linked programs, the thread-local variable ‘h_errno’ is not shared with
  3164. the main application.)
  3165. The ‘getXXXbyYYY’ functions are the most important functions in the
  3166. NSS modules. But there are others which implement the other ways to
  3167. access system databases (say for the password database, there are
  3168. ‘setpwent’, ‘getpwent’, and ‘endpwent’). These will be described in
  3169. more detail later. Here we give a general way to determine the
  3170. signature of the module function:
  3171. • the return value is ‘enum nss_status’;
  3172. • the name (*note NSS Module Names::);
  3173. • the first arguments are identical to the arguments of the
  3174. non-reentrant function;
  3175. • the next four arguments are:
  3176. ‘STRUCT_TYPE *result_buf’
  3177. pointer to buffer where the result is stored. ‘STRUCT_TYPE’
  3178. is normally a struct which corresponds to the database.
  3179. ‘char *buffer’
  3180. pointer to a buffer where the function can store additional
  3181. data for the result etc.
  3182. ‘size_t buflen’
  3183. length of the buffer pointed to by BUFFER.
  3184. ‘int *errnop’
  3185. the low-level error code to return to the application. If the
  3186. return value is not ‘NSS_STATUS_SUCCESS’, ‘*ERRNOP’ needs to
  3187. be set to a non-zero value. An NSS module should never set
  3188. ‘*ERRNOP’ to zero. The value ‘ERANGE’ is special, as
  3189. described above.
  3190. • possibly a last argument H_ERRNOP, for the host name and network
  3191. name lookup functions. If the return value is not
  3192. ‘NSS_STATUS_SUCCESS’, ‘*H_ERRNOP’ needs to be set to a non-zero
  3193. value. A generic error code is ‘NETDB_INTERNAL’, which instructs
  3194. the caller to examine ‘*ERRNOP’ for further details. (This
  3195. includes the ‘ERANGE’ special case.)
  3196. This table is correct for all functions but the ‘set…ent’ and ‘end…ent’
  3197. functions.
  3198. 
  3199. File: libc.info, Node: Extending NSS, Prev: NSS Module Internals, Up: Name Service Switch
  3200. 29.4 Extending NSS
  3201. ==================
  3202. One of the advantages of NSS mentioned above is that it can be extended
  3203. quite easily. There are two ways in which the extension can happen:
  3204. adding another database or adding another service. The former is
  3205. normally done only by the C library developers. It is here only
  3206. important to remember that adding another database is independent from
  3207. adding another service because a service need not support all databases
  3208. or lookup functions.
  3209. A designer/implementer of a new service is therefore free to choose
  3210. the databases s/he is interested in and leave the rest for later (or
  3211. completely aside).
  3212. * Menu:
  3213. * Adding another Service to NSS:: What is to do to add a new service.
  3214. * NSS Module Function Internals:: Guidelines for writing new NSS
  3215. service functions.
  3216. 
  3217. File: libc.info, Node: Adding another Service to NSS, Next: NSS Module Function Internals, Prev: Extending NSS, Up: Extending NSS
  3218. 29.4.1 Adding another Service to NSS
  3219. ------------------------------------
  3220. The sources for a new service need not (and should not) be part of the
  3221. GNU C Library itself. The developer retains complete control over the
  3222. sources and its development. The links between the C library and the
  3223. new service module consists solely of the interface functions.
  3224. Each module is designed following a specific interface specification.
  3225. For now the version is 2 (the interface in version 1 was not adequate)
  3226. and this manifests in the version number of the shared library object of
  3227. the NSS modules: they have the extension ‘.2’. If the interface changes
  3228. again in an incompatible way, this number will be increased. Modules
  3229. using the old interface will still be usable.
  3230. Developers of a new service will have to make sure that their module
  3231. is created using the correct interface number. This means the file
  3232. itself must have the correct name and on ELF systems the "soname"
  3233. (Shared Object Name) must also have this number. Building a module from
  3234. a bunch of object files on an ELF system using GNU CC could be done like
  3235. this:
  3236. gcc -shared -o libnss_NAME.so.2 -Wl,-soname,libnss_NAME.so.2 OBJECTS
  3237. *note Options for Linking: (gcc)Link Options, to learn more about this
  3238. command line.
  3239. To use the new module the library must be able to find it. This can
  3240. be achieved by using options for the dynamic linker so that it will
  3241. search the directory where the binary is placed. For an ELF system this
  3242. could be done by adding the wanted directory to the value of
  3243. ‘LD_LIBRARY_PATH’.
  3244. But this is not always possible since some programs (those which run
  3245. under IDs which do not belong to the user) ignore this variable.
  3246. Therefore the stable version of the module should be placed into a
  3247. directory which is searched by the dynamic linker. Normally this should
  3248. be the directory ‘$prefix/lib’, where ‘$prefix’ corresponds to the value
  3249. given to configure using the ‘--prefix’ option. But be careful: this
  3250. should only be done if it is clear the module does not cause any harm.
  3251. System administrators should be careful.
  3252. 
  3253. File: libc.info, Node: NSS Module Function Internals, Prev: Adding another Service to NSS, Up: Extending NSS
  3254. 29.4.2 Internals of the NSS Module Functions
  3255. --------------------------------------------
  3256. Until now we only provided the syntactic interface for the functions in
  3257. the NSS module. In fact there is not much more we can say since the
  3258. implementation obviously is different for each function. But a few
  3259. general rules must be followed by all functions.
  3260. In fact there are four kinds of different functions which may appear
  3261. in the interface. All derive from the traditional ones for system
  3262. databases. DB in the following table is normally an abbreviation for
  3263. the database (e.g., it is ‘pw’ for the password database).
  3264. ‘enum nss_status _nss_DATABASE_setDBent (void)’
  3265. This function prepares the service for following operations. For a
  3266. simple file based lookup this means files could be opened, for
  3267. other services this function simply is a noop.
  3268. One special case for this function is that it takes an additional
  3269. argument for some DATABASEs (i.e., the interface is ‘int setDBent
  3270. (int)’). *note Host Names::, which describes the ‘sethostent’
  3271. function.
  3272. The return value should be NSS_STATUS_SUCCESS or according to the
  3273. table above in case of an error (*note NSS Modules Interface::).
  3274. ‘enum nss_status _nss_DATABASE_endDBent (void)’
  3275. This function simply closes all files which are still open or
  3276. removes buffer caches. If there are no files or buffers to remove
  3277. this is again a simple noop.
  3278. There normally is no return value other than NSS_STATUS_SUCCESS.
  3279. ‘enum nss_status _nss_DATABASE_getDBent_r (STRUCTURE *result, char *buffer, size_t buflen, int *errnop)’
  3280. Since this function will be called several times in a row to
  3281. retrieve one entry after the other it must keep some kind of state.
  3282. But this also means the functions are not really reentrant. They
  3283. are reentrant only in that simultaneous calls to this function will
  3284. not try to write the retrieved data in the same place (as it would
  3285. be the case for the non-reentrant functions); instead, it writes to
  3286. the structure pointed to by the RESULT parameter. But the calls
  3287. share a common state and in the case of a file access this means
  3288. they return neighboring entries in the file.
  3289. The buffer of length BUFLEN pointed to by BUFFER can be used for
  3290. storing some additional data for the result. It is _not_
  3291. guaranteed that the same buffer will be passed for the next call of
  3292. this function. Therefore one must not misuse this buffer to save
  3293. some state information from one call to another.
  3294. Before the function returns with a failure code, the implementation
  3295. should store the value of the local ERRNO variable in the variable
  3296. pointed to be ERRNOP. This is important to guarantee the module
  3297. working in statically linked programs. The stored value must not
  3298. be zero.
  3299. As explained above this function could also have an additional last
  3300. argument. This depends on the database used; it happens only for
  3301. ‘host’ and ‘networks’.
  3302. The function shall return ‘NSS_STATUS_SUCCESS’ as long as there are
  3303. more entries. When the last entry was read it should return
  3304. ‘NSS_STATUS_NOTFOUND’. When the buffer given as an argument is too
  3305. small for the data to be returned ‘NSS_STATUS_TRYAGAIN’ should be
  3306. returned. When the service was not formerly initialized by a call
  3307. to ‘_nss_DATABASE_setDBent’ all return values allowed for this
  3308. function can also be returned here.
  3309. ‘enum nss_status _nss_DATABASE_getDBbyXX_r (PARAMS, STRUCTURE *result, char *buffer, size_t buflen, int *errnop)’
  3310. This function shall return the entry from the database which is
  3311. addressed by the PARAMS. The type and number of these arguments
  3312. vary. It must be individually determined by looking to the
  3313. user-level interface functions. All arguments given to the
  3314. non-reentrant version are here described by PARAMS.
  3315. The result must be stored in the structure pointed to by RESULT.
  3316. If there are additional data to return (say strings, where the
  3317. RESULT structure only contains pointers) the function must use the
  3318. BUFFER of length BUFLEN. There must not be any references to
  3319. non-constant global data.
  3320. The implementation of this function should honor the STAYOPEN flag
  3321. set by the ‘setDBent’ function whenever this makes sense.
  3322. Before the function returns, the implementation should store the
  3323. value of the local ERRNO variable in the variable pointed to by
  3324. ERRNOP. This is important to guarantee the module works in
  3325. statically linked programs.
  3326. Again, this function takes an additional last argument for the
  3327. ‘host’ and ‘networks’ database.
  3328. The return value should as always follow the rules given above
  3329. (*note NSS Modules Interface::).
  3330. 
  3331. File: libc.info, Node: Users and Groups, Next: System Management, Prev: Name Service Switch, Up: Top
  3332. 30 Users and Groups
  3333. *******************
  3334. Every user who can log in on the system is identified by a unique number
  3335. called the "user ID". Each process has an effective user ID which says
  3336. which user’s access permissions it has.
  3337. Users are classified into "groups" for access control purposes. Each
  3338. process has one or more "group ID values" which say which groups the
  3339. process can use for access to files.
  3340. The effective user and group IDs of a process collectively form its
  3341. "persona". This determines which files the process can access.
  3342. Normally, a process inherits its persona from the parent process, but
  3343. under special circumstances a process can change its persona and thus
  3344. change its access permissions.
  3345. Each file in the system also has a user ID and a group ID. Access
  3346. control works by comparing the user and group IDs of the file with those
  3347. of the running process.
  3348. The system keeps a database of all the registered users, and another
  3349. database of all the defined groups. There are library functions you can
  3350. use to examine these databases.
  3351. * Menu:
  3352. * User and Group IDs:: Each user has a unique numeric ID;
  3353. likewise for groups.
  3354. * Process Persona:: The user IDs and group IDs of a process.
  3355. * Why Change Persona:: Why a program might need to change
  3356. its user and/or group IDs.
  3357. * How Change Persona:: Changing the user and group IDs.
  3358. * Reading Persona:: How to examine the user and group IDs.
  3359. * Setting User ID:: Functions for setting the user ID.
  3360. * Setting Groups:: Functions for setting the group IDs.
  3361. * Enable/Disable Setuid:: Turning setuid access on and off.
  3362. * Setuid Program Example:: The pertinent parts of one sample program.
  3363. * Tips for Setuid:: How to avoid granting unlimited access.
  3364. * Who Logged In:: Getting the name of the user who logged in,
  3365. or of the real user ID of the current process.
  3366. * User Accounting Database:: Keeping information about users and various
  3367. actions in databases.
  3368. * User Database:: Functions and data structures for
  3369. accessing the user database.
  3370. * Group Database:: Functions and data structures for
  3371. accessing the group database.
  3372. * Database Example:: Example program showing the use of database
  3373. inquiry functions.
  3374. * Netgroup Database:: Functions for accessing the netgroup database.
  3375. 
  3376. File: libc.info, Node: User and Group IDs, Next: Process Persona, Up: Users and Groups
  3377. 30.1 User and Group IDs
  3378. =======================
  3379. Each user account on a computer system is identified by a "user name"
  3380. (or "login name") and "user ID". Normally, each user name has a unique
  3381. user ID, but it is possible for several login names to have the same
  3382. user ID. The user names and corresponding user IDs are stored in a data
  3383. base which you can access as described in *note User Database::.
  3384. Users are classified in "groups". Each user name belongs to one
  3385. "default group" and may also belong to any number of "supplementary
  3386. groups". Users who are members of the same group can share resources
  3387. (such as files) that are not accessible to users who are not a member of
  3388. that group. Each group has a "group name" and "group ID". *Note Group
  3389. Database::, for how to find information about a group ID or group name.
  3390. 
  3391. File: libc.info, Node: Process Persona, Next: Why Change Persona, Prev: User and Group IDs, Up: Users and Groups
  3392. 30.2 The Persona of a Process
  3393. =============================
  3394. At any time, each process has an "effective user ID", a "effective group
  3395. ID", and a set of "supplementary group IDs". These IDs determine the
  3396. privileges of the process. They are collectively called the "persona"
  3397. of the process, because they determine “who it is” for purposes of
  3398. access control.
  3399. Your login shell starts out with a persona which consists of your
  3400. user ID, your default group ID, and your supplementary group IDs (if you
  3401. are in more than one group). In normal circumstances, all your other
  3402. processes inherit these values.
  3403. A process also has a "real user ID" which identifies the user who
  3404. created the process, and a "real group ID" which identifies that user’s
  3405. default group. These values do not play a role in access control, so we
  3406. do not consider them part of the persona. But they are also important.
  3407. Both the real and effective user ID can be changed during the
  3408. lifetime of a process. *Note Why Change Persona::.
  3409. For details on how a process’s effective user ID and group IDs affect
  3410. its permission to access files, see *note Access Permission::.
  3411. The effective user ID of a process also controls permissions for
  3412. sending signals using the ‘kill’ function. *Note Signaling Another
  3413. Process::.
  3414. Finally, there are many operations which can only be performed by a
  3415. process whose effective user ID is zero. A process with this user ID is
  3416. a "privileged process". Commonly the user name ‘root’ is associated
  3417. with user ID 0, but there may be other user names with this ID.
  3418. 
  3419. File: libc.info, Node: Why Change Persona, Next: How Change Persona, Prev: Process Persona, Up: Users and Groups
  3420. 30.3 Why Change the Persona of a Process?
  3421. =========================================
  3422. The most obvious situation where it is necessary for a process to change
  3423. its user and/or group IDs is the ‘login’ program. When ‘login’ starts
  3424. running, its user ID is ‘root’. Its job is to start a shell whose user
  3425. and group IDs are those of the user who is logging in. (To accomplish
  3426. this fully, ‘login’ must set the real user and group IDs as well as its
  3427. persona. But this is a special case.)
  3428. The more common case of changing persona is when an ordinary user
  3429. program needs access to a resource that wouldn’t ordinarily be
  3430. accessible to the user actually running it.
  3431. For example, you may have a file that is controlled by your program
  3432. but that shouldn’t be read or modified directly by other users, either
  3433. because it implements some kind of locking protocol, or because you want
  3434. to preserve the integrity or privacy of the information it contains.
  3435. This kind of restricted access can be implemented by having the program
  3436. change its effective user or group ID to match that of the resource.
  3437. Thus, imagine a game program that saves scores in a file. The game
  3438. program itself needs to be able to update this file no matter who is
  3439. running it, but if users can write the file without going through the
  3440. game, they can give themselves any scores they like. Some people
  3441. consider this undesirable, or even reprehensible. It can be prevented
  3442. by creating a new user ID and login name (say, ‘games’) to own the
  3443. scores file, and make the file writable only by this user. Then, when
  3444. the game program wants to update this file, it can change its effective
  3445. user ID to be that for ‘games’. In effect, the program must adopt the
  3446. persona of ‘games’ so it can write to the scores file.
  3447. 
  3448. File: libc.info, Node: How Change Persona, Next: Reading Persona, Prev: Why Change Persona, Up: Users and Groups
  3449. 30.4 How an Application Can Change Persona
  3450. ==========================================
  3451. The ability to change the persona of a process can be a source of
  3452. unintentional privacy violations, or even intentional abuse. Because of
  3453. the potential for problems, changing persona is restricted to special
  3454. circumstances.
  3455. You can’t arbitrarily set your user ID or group ID to anything you
  3456. want; only privileged processes can do that. Instead, the normal way
  3457. for a program to change its persona is that it has been set up in
  3458. advance to change to a particular user or group. This is the function
  3459. of the setuid and setgid bits of a file’s access mode. *Note Permission
  3460. Bits::.
  3461. When the setuid bit of an executable file is on, executing that file
  3462. gives the process a third user ID: the "file user ID". This ID is set to
  3463. the owner ID of the file. The system then changes the effective user ID
  3464. to the file user ID. The real user ID remains as it was. Likewise, if
  3465. the setgid bit is on, the process is given a "file group ID" equal to
  3466. the group ID of the file, and its effective group ID is changed to the
  3467. file group ID.
  3468. If a process has a file ID (user or group), then it can at any time
  3469. change its effective ID to its real ID and back to its file ID. Programs
  3470. use this feature to relinquish their special privileges except when they
  3471. actually need them. This makes it less likely that they can be tricked
  3472. into doing something inappropriate with their privileges.
  3473. *Portability Note:* Older systems do not have file IDs. To determine
  3474. if a system has this feature, you can test the compiler define
  3475. ‘_POSIX_SAVED_IDS’. (In the POSIX standard, file IDs are known as saved
  3476. IDs.)
  3477. *Note File Attributes::, for a more general discussion of file modes
  3478. and accessibility.
  3479. 
  3480. File: libc.info, Node: Reading Persona, Next: Setting User ID, Prev: How Change Persona, Up: Users and Groups
  3481. 30.5 Reading the Persona of a Process
  3482. =====================================
  3483. Here are detailed descriptions of the functions for reading the user and
  3484. group IDs of a process, both real and effective. To use these
  3485. facilities, you must include the header files ‘sys/types.h’ and
  3486. ‘unistd.h’.
  3487. -- Data Type: uid_t
  3488. This is an integer data type used to represent user IDs. In the
  3489. GNU C Library, this is an alias for ‘unsigned int’.
  3490. -- Data Type: gid_t
  3491. This is an integer data type used to represent group IDs. In the
  3492. GNU C Library, this is an alias for ‘unsigned int’.
  3493. -- Function: uid_t getuid (void)
  3494. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3495. Concepts::.
  3496. The ‘getuid’ function returns the real user ID of the process.
  3497. -- Function: gid_t getgid (void)
  3498. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3499. Concepts::.
  3500. The ‘getgid’ function returns the real group ID of the process.
  3501. -- Function: uid_t geteuid (void)
  3502. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3503. Concepts::.
  3504. The ‘geteuid’ function returns the effective user ID of the
  3505. process.
  3506. -- Function: gid_t getegid (void)
  3507. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3508. Concepts::.
  3509. The ‘getegid’ function returns the effective group ID of the
  3510. process.
  3511. -- Function: int getgroups (int COUNT, gid_t *GROUPS)
  3512. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  3513. Concepts::.
  3514. The ‘getgroups’ function is used to inquire about the supplementary
  3515. group IDs of the process. Up to COUNT of these group IDs are
  3516. stored in the array GROUPS; the return value from the function is
  3517. the number of group IDs actually stored. If COUNT is smaller than
  3518. the total number of supplementary group IDs, then ‘getgroups’
  3519. returns a value of ‘-1’ and ‘errno’ is set to ‘EINVAL’.
  3520. If COUNT is zero, then ‘getgroups’ just returns the total number of
  3521. supplementary group IDs. On systems that do not support
  3522. supplementary groups, this will always be zero.
  3523. Here’s how to use ‘getgroups’ to read all the supplementary group
  3524. IDs:
  3525. gid_t *
  3526. read_all_groups (void)
  3527. {
  3528. int ngroups = getgroups (0, NULL);
  3529. gid_t *groups
  3530. = (gid_t *) xmalloc (ngroups * sizeof (gid_t));
  3531. int val = getgroups (ngroups, groups);
  3532. if (val < 0)
  3533. {
  3534. free (groups);
  3535. return NULL;
  3536. }
  3537. return groups;
  3538. }
  3539. 
  3540. File: libc.info, Node: Setting User ID, Next: Setting Groups, Prev: Reading Persona, Up: Users and Groups
  3541. 30.6 Setting the User ID
  3542. ========================
  3543. This section describes the functions for altering the user ID (real
  3544. and/or effective) of a process. To use these facilities, you must
  3545. include the header files ‘sys/types.h’ and ‘unistd.h’.
  3546. -- Function: int seteuid (uid_t NEWEUID)
  3547. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3548. POSIX Safety Concepts::.
  3549. This function sets the effective user ID of a process to NEWEUID,
  3550. provided that the process is allowed to change its effective user
  3551. ID. A privileged process (effective user ID zero) can change its
  3552. effective user ID to any legal value. An unprivileged process with
  3553. a file user ID can change its effective user ID to its real user ID
  3554. or to its file user ID. Otherwise, a process may not change its
  3555. effective user ID at all.
  3556. The ‘seteuid’ function returns a value of ‘0’ to indicate
  3557. successful completion, and a value of ‘-1’ to indicate an error.
  3558. The following ‘errno’ error conditions are defined for this
  3559. function:
  3560. ‘EINVAL’
  3561. The value of the NEWEUID argument is invalid.
  3562. ‘EPERM’
  3563. The process may not change to the specified ID.
  3564. Older systems (those without the ‘_POSIX_SAVED_IDS’ feature) do not
  3565. have this function.
  3566. -- Function: int setuid (uid_t NEWUID)
  3567. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3568. POSIX Safety Concepts::.
  3569. If the calling process is privileged, this function sets both the
  3570. real and effective user IDs of the process to NEWUID. It also
  3571. deletes the file user ID of the process, if any. NEWUID may be any
  3572. legal value. (Once this has been done, there is no way to recover
  3573. the old effective user ID.)
  3574. If the process is not privileged, and the system supports the
  3575. ‘_POSIX_SAVED_IDS’ feature, then this function behaves like
  3576. ‘seteuid’.
  3577. The return values and error conditions are the same as for
  3578. ‘seteuid’.
  3579. -- Function: int setreuid (uid_t RUID, uid_t EUID)
  3580. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3581. POSIX Safety Concepts::.
  3582. This function sets the real user ID of the process to RUID and the
  3583. effective user ID to EUID. If RUID is ‘-1’, it means not to change
  3584. the real user ID; likewise if EUID is ‘-1’, it means not to change
  3585. the effective user ID.
  3586. The ‘setreuid’ function exists for compatibility with 4.3 BSD Unix,
  3587. which does not support file IDs. You can use this function to swap
  3588. the effective and real user IDs of the process. (Privileged
  3589. processes are not limited to this particular usage.) If file IDs
  3590. are supported, you should use that feature instead of this
  3591. function. *Note Enable/Disable Setuid::.
  3592. The return value is ‘0’ on success and ‘-1’ on failure. The
  3593. following ‘errno’ error conditions are defined for this function:
  3594. ‘EPERM’
  3595. The process does not have the appropriate privileges; you do
  3596. not have permission to change to the specified ID.
  3597. 
  3598. File: libc.info, Node: Setting Groups, Next: Enable/Disable Setuid, Prev: Setting User ID, Up: Users and Groups
  3599. 30.7 Setting the Group IDs
  3600. ==========================
  3601. This section describes the functions for altering the group IDs (real
  3602. and effective) of a process. To use these facilities, you must include
  3603. the header files ‘sys/types.h’ and ‘unistd.h’.
  3604. -- Function: int setegid (gid_t NEWGID)
  3605. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3606. POSIX Safety Concepts::.
  3607. This function sets the effective group ID of the process to NEWGID,
  3608. provided that the process is allowed to change its group ID. Just
  3609. as with ‘seteuid’, if the process is privileged it may change its
  3610. effective group ID to any value; if it isn’t, but it has a file
  3611. group ID, then it may change to its real group ID or file group ID;
  3612. otherwise it may not change its effective group ID.
  3613. Note that a process is only privileged if its effective _user_ ID
  3614. is zero. The effective group ID only affects access permissions.
  3615. The return values and error conditions for ‘setegid’ are the same
  3616. as those for ‘seteuid’.
  3617. This function is only present if ‘_POSIX_SAVED_IDS’ is defined.
  3618. -- Function: int setgid (gid_t NEWGID)
  3619. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3620. POSIX Safety Concepts::.
  3621. This function sets both the real and effective group ID of the
  3622. process to NEWGID, provided that the process is privileged. It
  3623. also deletes the file group ID, if any.
  3624. If the process is not privileged, then ‘setgid’ behaves like
  3625. ‘setegid’.
  3626. The return values and error conditions for ‘setgid’ are the same as
  3627. those for ‘seteuid’.
  3628. -- Function: int setregid (gid_t RGID, gid_t EGID)
  3629. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3630. POSIX Safety Concepts::.
  3631. This function sets the real group ID of the process to RGID and the
  3632. effective group ID to EGID. If RGID is ‘-1’, it means not to
  3633. change the real group ID; likewise if EGID is ‘-1’, it means not to
  3634. change the effective group ID.
  3635. The ‘setregid’ function is provided for compatibility with 4.3 BSD
  3636. Unix, which does not support file IDs. You can use this function
  3637. to swap the effective and real group IDs of the process.
  3638. (Privileged processes are not limited to this usage.) If file IDs
  3639. are supported, you should use that feature instead of using this
  3640. function. *Note Enable/Disable Setuid::.
  3641. The return values and error conditions for ‘setregid’ are the same
  3642. as those for ‘setreuid’.
  3643. ‘setuid’ and ‘setgid’ behave differently depending on whether the
  3644. effective user ID at the time is zero. If it is not zero, they behave
  3645. like ‘seteuid’ and ‘setegid’. If it is, they change both effective and
  3646. real IDs and delete the file ID. To avoid confusion, we recommend you
  3647. always use ‘seteuid’ and ‘setegid’ except when you know the effective
  3648. user ID is zero and your intent is to change the persona permanently.
  3649. This case is rare—most of the programs that need it, such as ‘login’ and
  3650. ‘su’, have already been written.
  3651. Note that if your program is setuid to some user other than ‘root’,
  3652. there is no way to drop privileges permanently.
  3653. The system also lets privileged processes change their supplementary
  3654. group IDs. To use ‘setgroups’ or ‘initgroups’, your programs should
  3655. include the header file ‘grp.h’.
  3656. -- Function: int setgroups (size_t COUNT, const gid_t *GROUPS)
  3657. Preliminary: | MT-Safe | AS-Unsafe lock | AC-Unsafe lock | *Note
  3658. POSIX Safety Concepts::.
  3659. This function sets the process’s supplementary group IDs. It can
  3660. only be called from privileged processes. The COUNT argument
  3661. specifies the number of group IDs in the array GROUPS.
  3662. This function returns ‘0’ if successful and ‘-1’ on error. The
  3663. following ‘errno’ error conditions are defined for this function:
  3664. ‘EPERM’
  3665. The calling process is not privileged.
  3666. -- Function: int initgroups (const char *USER, gid_t GROUP)
  3667. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  3668. AC-Unsafe corrupt mem fd lock | *Note POSIX Safety Concepts::.
  3669. The ‘initgroups’ function sets the process’s supplementary group
  3670. IDs to be the normal default for the user name USER. The group
  3671. GROUP is automatically included.
  3672. This function works by scanning the group database for all the
  3673. groups USER belongs to. It then calls ‘setgroups’ with the list it
  3674. has constructed.
  3675. The return values and error conditions are the same as for
  3676. ‘setgroups’.
  3677. If you are interested in the groups a particular user belongs to, but
  3678. do not want to change the process’s supplementary group IDs, you can use
  3679. ‘getgrouplist’. To use ‘getgrouplist’, your programs should include the
  3680. header file ‘grp.h’.
  3681. -- Function: int getgrouplist (const char *USER, gid_t GROUP, gid_t
  3682. *GROUPS, int *NGROUPS)
  3683. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  3684. AC-Unsafe corrupt mem fd lock | *Note POSIX Safety Concepts::.
  3685. The ‘getgrouplist’ function scans the group database for all the
  3686. groups USER belongs to. Up to *NGROUPS group IDs corresponding to
  3687. these groups are stored in the array GROUPS; the return value from
  3688. the function is the number of group IDs actually stored. If
  3689. *NGROUPS is smaller than the total number of groups found, then
  3690. ‘getgrouplist’ returns a value of ‘-1’ and stores the actual number
  3691. of groups in *NGROUPS. The group GROUP is automatically included
  3692. in the list of groups returned by ‘getgrouplist’.
  3693. Here’s how to use ‘getgrouplist’ to read all supplementary groups
  3694. for USER:
  3695. gid_t *
  3696. supplementary_groups (char *user)
  3697. {
  3698. int ngroups = 16;
  3699. gid_t *groups
  3700. = (gid_t *) xmalloc (ngroups * sizeof (gid_t));
  3701. struct passwd *pw = getpwnam (user);
  3702. if (pw == NULL)
  3703. return NULL;
  3704. if (getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups) < 0)
  3705. {
  3706. groups = xrealloc (ngroups * sizeof (gid_t));
  3707. getgrouplist (pw->pw_name, pw->pw_gid, groups, &ngroups);
  3708. }
  3709. return groups;
  3710. }
  3711. 
  3712. File: libc.info, Node: Enable/Disable Setuid, Next: Setuid Program Example, Prev: Setting Groups, Up: Users and Groups
  3713. 30.8 Enabling and Disabling Setuid Access
  3714. =========================================
  3715. A typical setuid program does not need its special access all of the
  3716. time. It’s a good idea to turn off this access when it isn’t needed, so
  3717. it can’t possibly give unintended access.
  3718. If the system supports the ‘_POSIX_SAVED_IDS’ feature, you can
  3719. accomplish this with ‘seteuid’. When the game program starts, its real
  3720. user ID is ‘jdoe’, its effective user ID is ‘games’, and its saved user
  3721. ID is also ‘games’. The program should record both user ID values once
  3722. at the beginning, like this:
  3723. user_user_id = getuid ();
  3724. game_user_id = geteuid ();
  3725. Then it can turn off game file access with
  3726. seteuid (user_user_id);
  3727. and turn it on with
  3728. seteuid (game_user_id);
  3729. Throughout this process, the real user ID remains ‘jdoe’ and the file
  3730. user ID remains ‘games’, so the program can always set its effective
  3731. user ID to either one.
  3732. On other systems that don’t support file user IDs, you can turn
  3733. setuid access on and off by using ‘setreuid’ to swap the real and
  3734. effective user IDs of the process, as follows:
  3735. setreuid (geteuid (), getuid ());
  3736. This special case is always allowed—it cannot fail.
  3737. Why does this have the effect of toggling the setuid access? Suppose
  3738. a game program has just started, and its real user ID is ‘jdoe’ while
  3739. its effective user ID is ‘games’. In this state, the game can write the
  3740. scores file. If it swaps the two uids, the real becomes ‘games’ and the
  3741. effective becomes ‘jdoe’; now the program has only ‘jdoe’ access.
  3742. Another swap brings ‘games’ back to the effective user ID and restores
  3743. access to the scores file.
  3744. In order to handle both kinds of systems, test for the saved user ID
  3745. feature with a preprocessor conditional, like this:
  3746. #ifdef _POSIX_SAVED_IDS
  3747. seteuid (user_user_id);
  3748. #else
  3749. setreuid (geteuid (), getuid ());
  3750. #endif
  3751. 
  3752. File: libc.info, Node: Setuid Program Example, Next: Tips for Setuid, Prev: Enable/Disable Setuid, Up: Users and Groups
  3753. 30.9 Setuid Program Example
  3754. ===========================
  3755. Here’s an example showing how to set up a program that changes its
  3756. effective user ID.
  3757. This is part of a game program called ‘caber-toss’ that manipulates a
  3758. file ‘scores’ that should be writable only by the game program itself.
  3759. The program assumes that its executable file will be installed with the
  3760. setuid bit set and owned by the same user as the ‘scores’ file.
  3761. Typically, a system administrator will set up an account like ‘games’
  3762. for this purpose.
  3763. The executable file is given mode ‘4755’, so that doing an ‘ls -l’ on
  3764. it produces output like:
  3765. -rwsr-xr-x 1 games 184422 Jul 30 15:17 caber-toss
  3766. The setuid bit shows up in the file modes as the ‘s’.
  3767. The scores file is given mode ‘644’, and doing an ‘ls -l’ on it
  3768. shows:
  3769. -rw-r--r-- 1 games 0 Jul 31 15:33 scores
  3770. Here are the parts of the program that show how to set up the changed
  3771. user ID. This program is conditionalized so that it makes use of the
  3772. file IDs feature if it is supported, and otherwise uses ‘setreuid’ to
  3773. swap the effective and real user IDs.
  3774. #include <stdio.h>
  3775. #include <sys/types.h>
  3776. #include <unistd.h>
  3777. #include <stdlib.h>
  3778. /* Remember the effective and real UIDs. */
  3779. static uid_t euid, ruid;
  3780. /* Restore the effective UID to its original value. */
  3781. void
  3782. do_setuid (void)
  3783. {
  3784. int status;
  3785. #ifdef _POSIX_SAVED_IDS
  3786. status = seteuid (euid);
  3787. #else
  3788. status = setreuid (ruid, euid);
  3789. #endif
  3790. if (status < 0) {
  3791. fprintf (stderr, "Couldn't set uid.\n");
  3792. exit (status);
  3793. }
  3794. }
  3795. /* Set the effective UID to the real UID. */
  3796. void
  3797. undo_setuid (void)
  3798. {
  3799. int status;
  3800. #ifdef _POSIX_SAVED_IDS
  3801. status = seteuid (ruid);
  3802. #else
  3803. status = setreuid (euid, ruid);
  3804. #endif
  3805. if (status < 0) {
  3806. fprintf (stderr, "Couldn't set uid.\n");
  3807. exit (status);
  3808. }
  3809. }
  3810. /* Main program. */
  3811. int
  3812. main (void)
  3813. {
  3814. /* Remember the real and effective user IDs. */
  3815. ruid = getuid ();
  3816. euid = geteuid ();
  3817. undo_setuid ();
  3818. /* Do the game and record the score. */
  3819. }
  3820. Notice how the first thing the ‘main’ function does is to set the
  3821. effective user ID back to the real user ID. This is so that any other
  3822. file accesses that are performed while the user is playing the game use
  3823. the real user ID for determining permissions. Only when the program
  3824. needs to open the scores file does it switch back to the file user ID,
  3825. like this:
  3826. /* Record the score. */
  3827. int
  3828. record_score (int score)
  3829. {
  3830. FILE *stream;
  3831. char *myname;
  3832. /* Open the scores file. */
  3833. do_setuid ();
  3834. stream = fopen (SCORES_FILE, "a");
  3835. undo_setuid ();
  3836. /* Write the score to the file. */
  3837. if (stream)
  3838. {
  3839. myname = cuserid (NULL);
  3840. if (score < 0)
  3841. fprintf (stream, "%10s: Couldn't lift the caber.\n", myname);
  3842. else
  3843. fprintf (stream, "%10s: %d feet.\n", myname, score);
  3844. fclose (stream);
  3845. return 0;
  3846. }
  3847. else
  3848. return -1;
  3849. }
  3850. 
  3851. File: libc.info, Node: Tips for Setuid, Next: Who Logged In, Prev: Setuid Program Example, Up: Users and Groups
  3852. 30.10 Tips for Writing Setuid Programs
  3853. ======================================
  3854. It is easy for setuid programs to give the user access that isn’t
  3855. intended—in fact, if you want to avoid this, you need to be careful.
  3856. Here are some guidelines for preventing unintended access and minimizing
  3857. its consequences when it does occur:
  3858. • Don’t have ‘setuid’ programs with privileged user IDs such as
  3859. ‘root’ unless it is absolutely necessary. If the resource is
  3860. specific to your particular program, it’s better to define a new,
  3861. nonprivileged user ID or group ID just to manage that resource.
  3862. It’s better if you can write your program to use a special group
  3863. than a special user.
  3864. • Be cautious about using the ‘exec’ functions in combination with
  3865. changing the effective user ID. Don’t let users of your program
  3866. execute arbitrary programs under a changed user ID. Executing a
  3867. shell is especially bad news. Less obviously, the ‘execlp’ and
  3868. ‘execvp’ functions are a potential risk (since the program they
  3869. execute depends on the user’s ‘PATH’ environment variable).
  3870. If you must ‘exec’ another program under a changed ID, specify an
  3871. absolute file name (*note File Name Resolution::) for the
  3872. executable, and make sure that the protections on that executable
  3873. and _all_ containing directories are such that ordinary users
  3874. cannot replace it with some other program.
  3875. You should also check the arguments passed to the program to make
  3876. sure they do not have unexpected effects. Likewise, you should
  3877. examine the environment variables. Decide which arguments and
  3878. variables are safe, and reject all others.
  3879. You should never use ‘system’ in a privileged program, because it
  3880. invokes a shell.
  3881. • Only use the user ID controlling the resource in the part of the
  3882. program that actually uses that resource. When you’re finished
  3883. with it, restore the effective user ID back to the actual user’s
  3884. user ID. *Note Enable/Disable Setuid::.
  3885. • If the ‘setuid’ part of your program needs to access other files
  3886. besides the controlled resource, it should verify that the real
  3887. user would ordinarily have permission to access those files. You
  3888. can use the ‘access’ function (*note Access Permission::) to check
  3889. this; it uses the real user and group IDs, rather than the
  3890. effective IDs.
  3891. 
  3892. File: libc.info, Node: Who Logged In, Next: User Accounting Database, Prev: Tips for Setuid, Up: Users and Groups
  3893. 30.11 Identifying Who Logged In
  3894. ===============================
  3895. You can use the functions listed in this section to determine the login
  3896. name of the user who is running a process, and the name of the user who
  3897. logged in the current session. See also the function ‘getuid’ and
  3898. friends (*note Reading Persona::). How this information is collected by
  3899. the system and how to control/add/remove information from the background
  3900. storage is described in *note User Accounting Database::.
  3901. The ‘getlogin’ function is declared in ‘unistd.h’, while ‘cuserid’
  3902. and ‘L_cuserid’ are declared in ‘stdio.h’.
  3903. -- Function: char * getlogin (void)
  3904. Preliminary: | MT-Unsafe race:getlogin race:utent sig:ALRM timer
  3905. locale | AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock
  3906. fd mem | *Note POSIX Safety Concepts::.
  3907. The ‘getlogin’ function returns a pointer to a string containing
  3908. the name of the user logged in on the controlling terminal of the
  3909. process, or a null pointer if this information cannot be
  3910. determined. The string is statically allocated and might be
  3911. overwritten on subsequent calls to this function or to ‘cuserid’.
  3912. -- Function: char * cuserid (char *STRING)
  3913. Preliminary: | MT-Unsafe race:cuserid/!string locale | AS-Unsafe
  3914. dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note
  3915. POSIX Safety Concepts::.
  3916. The ‘cuserid’ function returns a pointer to a string containing a
  3917. user name associated with the effective ID of the process. If
  3918. STRING is not a null pointer, it should be an array that can hold
  3919. at least ‘L_cuserid’ characters; the string is returned in this
  3920. array. Otherwise, a pointer to a string in a static area is
  3921. returned. This string is statically allocated and might be
  3922. overwritten on subsequent calls to this function or to ‘getlogin’.
  3923. The use of this function is deprecated since it is marked to be
  3924. withdrawn in XPG4.2 and has already been removed from newer
  3925. revisions of POSIX.1.
  3926. -- Macro: int L_cuserid
  3927. An integer constant that indicates how long an array you might need
  3928. to store a user name.
  3929. These functions let your program identify positively the user who is
  3930. running or the user who logged in this session. (These can differ when
  3931. setuid programs are involved; see *note Process Persona::.) The user
  3932. cannot do anything to fool these functions.
  3933. For most purposes, it is more useful to use the environment variable
  3934. ‘LOGNAME’ to find out who the user is. This is more flexible precisely
  3935. because the user can set ‘LOGNAME’ arbitrarily. *Note Standard
  3936. Environment::.
  3937. 
  3938. File: libc.info, Node: User Accounting Database, Next: User Database, Prev: Who Logged In, Up: Users and Groups
  3939. 30.12 The User Accounting Database
  3940. ==================================
  3941. Most Unix-like operating systems keep track of logged in users by
  3942. maintaining a user accounting database. This user accounting database
  3943. stores for each terminal, who has logged on, at what time, the process
  3944. ID of the user’s login shell, etc., etc., but also stores information
  3945. about the run level of the system, the time of the last system reboot,
  3946. and possibly more.
  3947. The user accounting database typically lives in ‘/etc/utmp’,
  3948. ‘/var/adm/utmp’ or ‘/var/run/utmp’. However, these files should *never*
  3949. be accessed directly. For reading information from and writing
  3950. information to the user accounting database, the functions described in
  3951. this section should be used.
  3952. * Menu:
  3953. * Manipulating the Database:: Scanning and modifying the user
  3954. accounting database.
  3955. * XPG Functions:: A standardized way for doing the same thing.
  3956. * Logging In and Out:: Functions from BSD that modify the user
  3957. accounting database.
  3958. 
  3959. File: libc.info, Node: Manipulating the Database, Next: XPG Functions, Up: User Accounting Database
  3960. 30.12.1 Manipulating the User Accounting Database
  3961. -------------------------------------------------
  3962. These functions and the corresponding data structures are declared in
  3963. the header file ‘utmp.h’.
  3964. -- Data Type: struct exit_status
  3965. The ‘exit_status’ data structure is used to hold information about
  3966. the exit status of processes marked as ‘DEAD_PROCESS’ in the user
  3967. accounting database.
  3968. ‘short int e_termination’
  3969. The exit status of the process.
  3970. ‘short int e_exit’
  3971. The exit status of the process.
  3972. -- Data Type: struct utmp
  3973. The ‘utmp’ data structure is used to hold information about entries
  3974. in the user accounting database. On GNU systems it has the
  3975. following members:
  3976. ‘short int ut_type’
  3977. Specifies the type of login; one of ‘EMPTY’, ‘RUN_LVL’,
  3978. ‘BOOT_TIME’, ‘OLD_TIME’, ‘NEW_TIME’, ‘INIT_PROCESS’,
  3979. ‘LOGIN_PROCESS’, ‘USER_PROCESS’, ‘DEAD_PROCESS’ or
  3980. ‘ACCOUNTING’.
  3981. ‘pid_t ut_pid’
  3982. The process ID number of the login process.
  3983. ‘char ut_line[]’
  3984. The device name of the tty (without ‘/dev/’).
  3985. ‘char ut_id[]’
  3986. The inittab ID of the process.
  3987. ‘char ut_user[]’
  3988. The user’s login name.
  3989. ‘char ut_host[]’
  3990. The name of the host from which the user logged in.
  3991. ‘struct exit_status ut_exit’
  3992. The exit status of a process marked as ‘DEAD_PROCESS’.
  3993. ‘long ut_session’
  3994. The Session ID, used for windowing.
  3995. ‘struct timeval ut_tv’
  3996. Time the entry was made. For entries of type ‘OLD_TIME’ this
  3997. is the time when the system clock changed, and for entries of
  3998. type ‘NEW_TIME’ this is the time the system clock was set to.
  3999. ‘int32_t ut_addr_v6[4]’
  4000. The Internet address of a remote host.
  4001. The ‘ut_type’, ‘ut_pid’, ‘ut_id’, ‘ut_tv’, and ‘ut_host’ fields are
  4002. not available on all systems. Portable applications therefore should be
  4003. prepared for these situations. To help do this the ‘utmp.h’ header
  4004. provides macros ‘_HAVE_UT_TYPE’, ‘_HAVE_UT_PID’, ‘_HAVE_UT_ID’,
  4005. ‘_HAVE_UT_TV’, and ‘_HAVE_UT_HOST’ if the respective field is available.
  4006. The programmer can handle the situations by using ‘#ifdef’ in the
  4007. program code.
  4008. The following macros are defined for use as values for the ‘ut_type’
  4009. member of the ‘utmp’ structure. The values are integer constants.
  4010. ‘EMPTY’
  4011. This macro is used to indicate that the entry contains no valid
  4012. user accounting information.
  4013. ‘RUN_LVL’
  4014. This macro is used to identify the system’s runlevel.
  4015. ‘BOOT_TIME’
  4016. This macro is used to identify the time of system boot.
  4017. ‘OLD_TIME’
  4018. This macro is used to identify the time when the system clock
  4019. changed.
  4020. ‘NEW_TIME’
  4021. This macro is used to identify the time after the system clock
  4022. changed.
  4023. ‘INIT_PROCESS’
  4024. This macro is used to identify a process spawned by the init
  4025. process.
  4026. ‘LOGIN_PROCESS’
  4027. This macro is used to identify the session leader of a logged in
  4028. user.
  4029. ‘USER_PROCESS’
  4030. This macro is used to identify a user process.
  4031. ‘DEAD_PROCESS’
  4032. This macro is used to identify a terminated process.
  4033. ‘ACCOUNTING’
  4034. ???
  4035. The size of the ‘ut_line’, ‘ut_id’, ‘ut_user’ and ‘ut_host’ arrays
  4036. can be found using the ‘sizeof’ operator.
  4037. Many older systems have, instead of an ‘ut_tv’ member, an ‘ut_time’
  4038. member, usually of type ‘time_t’, for representing the time associated
  4039. with the entry. Therefore, for backwards compatibility only, ‘utmp.h’
  4040. defines ‘ut_time’ as an alias for ‘ut_tv.tv_sec’.
  4041. -- Function: void setutent (void)
  4042. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4043. lock fd | *Note POSIX Safety Concepts::.
  4044. This function opens the user accounting database to begin scanning
  4045. it. You can then call ‘getutent’, ‘getutid’ or ‘getutline’ to read
  4046. entries and ‘pututline’ to write entries.
  4047. If the database is already open, it resets the input to the
  4048. beginning of the database.
  4049. -- Function: struct utmp * getutent (void)
  4050. Preliminary: | MT-Unsafe init race:utent race:utentbuf sig:ALRM
  4051. timer | AS-Unsafe heap lock | AC-Unsafe lock fd mem | *Note POSIX
  4052. Safety Concepts::.
  4053. The ‘getutent’ function reads the next entry from the user
  4054. accounting database. It returns a pointer to the entry, which is
  4055. statically allocated and may be overwritten by subsequent calls to
  4056. ‘getutent’. You must copy the contents of the structure if you
  4057. wish to save the information or you can use the ‘getutent_r’
  4058. function which stores the data in a user-provided buffer.
  4059. A null pointer is returned in case no further entry is available.
  4060. -- Function: void endutent (void)
  4061. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4062. lock fd | *Note POSIX Safety Concepts::.
  4063. This function closes the user accounting database.
  4064. -- Function: struct utmp * getutid (const struct utmp *ID)
  4065. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4066. lock heap | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  4067. This function searches forward from the current point in the
  4068. database for an entry that matches ID. If the ‘ut_type’ member of
  4069. the ID structure is one of ‘RUN_LVL’, ‘BOOT_TIME’, ‘OLD_TIME’ or
  4070. ‘NEW_TIME’ the entries match if the ‘ut_type’ members are
  4071. identical. If the ‘ut_type’ member of the ID structure is
  4072. ‘INIT_PROCESS’, ‘LOGIN_PROCESS’, ‘USER_PROCESS’ or ‘DEAD_PROCESS’,
  4073. the entries match if the ‘ut_type’ member of the entry read from
  4074. the database is one of these four, and the ‘ut_id’ members match.
  4075. However if the ‘ut_id’ member of either the ID structure or the
  4076. entry read from the database is empty it checks if the ‘ut_line’
  4077. members match instead. If a matching entry is found, ‘getutid’
  4078. returns a pointer to the entry, which is statically allocated, and
  4079. may be overwritten by a subsequent call to ‘getutent’, ‘getutid’ or
  4080. ‘getutline’. You must copy the contents of the structure if you
  4081. wish to save the information.
  4082. A null pointer is returned in case the end of the database is
  4083. reached without a match.
  4084. The ‘getutid’ function may cache the last read entry. Therefore,
  4085. if you are using ‘getutid’ to search for multiple occurrences, it
  4086. is necessary to zero out the static data after each call.
  4087. Otherwise ‘getutid’ could just return a pointer to the same entry
  4088. over and over again.
  4089. -- Function: struct utmp * getutline (const struct utmp *LINE)
  4090. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4091. heap lock | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4092. This function searches forward from the current point in the
  4093. database until it finds an entry whose ‘ut_type’ value is
  4094. ‘LOGIN_PROCESS’ or ‘USER_PROCESS’, and whose ‘ut_line’ member
  4095. matches the ‘ut_line’ member of the LINE structure. If it finds
  4096. such an entry, it returns a pointer to the entry which is
  4097. statically allocated, and may be overwritten by a subsequent call
  4098. to ‘getutent’, ‘getutid’ or ‘getutline’. You must copy the
  4099. contents of the structure if you wish to save the information.
  4100. A null pointer is returned in case the end of the database is
  4101. reached without a match.
  4102. The ‘getutline’ function may cache the last read entry. Therefore
  4103. if you are using ‘getutline’ to search for multiple occurrences, it
  4104. is necessary to zero out the static data after each call.
  4105. Otherwise ‘getutline’ could just return a pointer to the same entry
  4106. over and over again.
  4107. -- Function: struct utmp * pututline (const struct utmp *UTMP)
  4108. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4109. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4110. The ‘pututline’ function inserts the entry ‘*UTMP’ at the
  4111. appropriate place in the user accounting database. If it finds
  4112. that it is not already at the correct place in the database, it
  4113. uses ‘getutid’ to search for the position to insert the entry,
  4114. however this will not modify the static structure returned by
  4115. ‘getutent’, ‘getutid’ and ‘getutline’. If this search fails, the
  4116. entry is appended to the database.
  4117. The ‘pututline’ function returns a pointer to a copy of the entry
  4118. inserted in the user accounting database, or a null pointer if the
  4119. entry could not be added. The following ‘errno’ error conditions
  4120. are defined for this function:
  4121. ‘EPERM’
  4122. The process does not have the appropriate privileges; you
  4123. cannot modify the user accounting database.
  4124. All the ‘get*’ functions mentioned before store the information they
  4125. return in a static buffer. This can be a problem in multi-threaded
  4126. programs since the data returned for the request is overwritten by the
  4127. return value data in another thread. Therefore the GNU C Library
  4128. provides as extensions three more functions which return the data in a
  4129. user-provided buffer.
  4130. -- Function: int getutent_r (struct utmp *BUFFER, struct utmp **RESULT)
  4131. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4132. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4133. The ‘getutent_r’ is equivalent to the ‘getutent’ function. It
  4134. returns the next entry from the database. But instead of storing
  4135. the information in a static buffer it stores it in the buffer
  4136. pointed to by the parameter BUFFER.
  4137. If the call was successful, the function returns ‘0’ and the
  4138. pointer variable pointed to by the parameter RESULT contains a
  4139. pointer to the buffer which contains the result (this is most
  4140. probably the same value as BUFFER). If something went wrong during
  4141. the execution of ‘getutent_r’ the function returns ‘-1’.
  4142. This function is a GNU extension.
  4143. -- Function: int getutid_r (const struct utmp *ID, struct utmp *BUFFER,
  4144. struct utmp **RESULT)
  4145. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4146. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4147. This function retrieves just like ‘getutid’ the next entry matching
  4148. the information stored in ID. But the result is stored in the
  4149. buffer pointed to by the parameter BUFFER.
  4150. If successful the function returns ‘0’ and the pointer variable
  4151. pointed to by the parameter RESULT contains a pointer to the buffer
  4152. with the result (probably the same as RESULT. If not successful
  4153. the function return ‘-1’.
  4154. This function is a GNU extension.
  4155. -- Function: int getutline_r (const struct utmp *LINE, struct utmp
  4156. *BUFFER, struct utmp **RESULT)
  4157. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4158. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4159. This function retrieves just like ‘getutline’ the next entry
  4160. matching the information stored in LINE. But the result is stored
  4161. in the buffer pointed to by the parameter BUFFER.
  4162. If successful the function returns ‘0’ and the pointer variable
  4163. pointed to by the parameter RESULT contains a pointer to the buffer
  4164. with the result (probably the same as RESULT. If not successful
  4165. the function return ‘-1’.
  4166. This function is a GNU extension.
  4167. In addition to the user accounting database, most systems keep a
  4168. number of similar databases. For example most systems keep a log file
  4169. with all previous logins (usually in ‘/etc/wtmp’ or ‘/var/log/wtmp’).
  4170. For specifying which database to examine, the following function
  4171. should be used.
  4172. -- Function: int utmpname (const char *FILE)
  4173. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock heap |
  4174. AC-Unsafe lock mem | *Note POSIX Safety Concepts::.
  4175. The ‘utmpname’ function changes the name of the database to be
  4176. examined to FILE, and closes any previously opened database. By
  4177. default ‘getutent’, ‘getutid’, ‘getutline’ and ‘pututline’ read
  4178. from and write to the user accounting database.
  4179. The following macros are defined for use as the FILE argument:
  4180. -- Macro: char * _PATH_UTMP
  4181. This macro is used to specify the user accounting database.
  4182. -- Macro: char * _PATH_WTMP
  4183. This macro is used to specify the user accounting log file.
  4184. The ‘utmpname’ function returns a value of ‘0’ if the new name was
  4185. successfully stored, and a value of ‘-1’ to indicate an error.
  4186. Note that ‘utmpname’ does not try to open the database, and that
  4187. therefore the return value does not say anything about whether the
  4188. database can be successfully opened.
  4189. Specially for maintaining log-like databases the GNU C Library
  4190. provides the following function:
  4191. -- Function: void updwtmp (const char *WTMP_FILE, const struct utmp
  4192. *UTMP)
  4193. Preliminary: | MT-Unsafe sig:ALRM timer | AS-Unsafe | AC-Unsafe fd
  4194. | *Note POSIX Safety Concepts::.
  4195. The ‘updwtmp’ function appends the entry *UTMP to the database
  4196. specified by WTMP_FILE. For possible values for the WTMP_FILE
  4197. argument see the ‘utmpname’ function.
  4198. *Portability Note:* Although many operating systems provide a subset
  4199. of these functions, they are not standardized. There are often subtle
  4200. differences in the return types, and there are considerable differences
  4201. between the various definitions of ‘struct utmp’. When programming for
  4202. the GNU C Library, it is probably best to stick with the functions
  4203. described in this section. If however, you want your program to be
  4204. portable, consider using the XPG functions described in *note XPG
  4205. Functions::, or take a look at the BSD compatible functions in *note
  4206. Logging In and Out::.
  4207. 
  4208. File: libc.info, Node: XPG Functions, Next: Logging In and Out, Prev: Manipulating the Database, Up: User Accounting Database
  4209. 30.12.2 XPG User Accounting Database Functions
  4210. ----------------------------------------------
  4211. These functions, described in the X/Open Portability Guide, are declared
  4212. in the header file ‘utmpx.h’.
  4213. -- Data Type: struct utmpx
  4214. The ‘utmpx’ data structure contains at least the following members:
  4215. ‘short int ut_type’
  4216. Specifies the type of login; one of ‘EMPTY’, ‘RUN_LVL’,
  4217. ‘BOOT_TIME’, ‘OLD_TIME’, ‘NEW_TIME’, ‘INIT_PROCESS’,
  4218. ‘LOGIN_PROCESS’, ‘USER_PROCESS’ or ‘DEAD_PROCESS’.
  4219. ‘pid_t ut_pid’
  4220. The process ID number of the login process.
  4221. ‘char ut_line[]’
  4222. The device name of the tty (without ‘/dev/’).
  4223. ‘char ut_id[]’
  4224. The inittab ID of the process.
  4225. ‘char ut_user[]’
  4226. The user’s login name.
  4227. ‘struct timeval ut_tv’
  4228. Time the entry was made. For entries of type ‘OLD_TIME’ this
  4229. is the time when the system clock changed, and for entries of
  4230. type ‘NEW_TIME’ this is the time the system clock was set to.
  4231. In the GNU C Library, ‘struct utmpx’ is identical to ‘struct utmp’
  4232. except for the fact that including ‘utmpx.h’ does not make visible
  4233. the declaration of ‘struct exit_status’.
  4234. The following macros are defined for use as values for the ‘ut_type’
  4235. member of the ‘utmpx’ structure. The values are integer constants and
  4236. are, in the GNU C Library, identical to the definitions in ‘utmp.h’.
  4237. ‘EMPTY’
  4238. This macro is used to indicate that the entry contains no valid
  4239. user accounting information.
  4240. ‘RUN_LVL’
  4241. This macro is used to identify the system’s runlevel.
  4242. ‘BOOT_TIME’
  4243. This macro is used to identify the time of system boot.
  4244. ‘OLD_TIME’
  4245. This macro is used to identify the time when the system clock
  4246. changed.
  4247. ‘NEW_TIME’
  4248. This macro is used to identify the time after the system clock
  4249. changed.
  4250. ‘INIT_PROCESS’
  4251. This macro is used to identify a process spawned by the init
  4252. process.
  4253. ‘LOGIN_PROCESS’
  4254. This macro is used to identify the session leader of a logged in
  4255. user.
  4256. ‘USER_PROCESS’
  4257. This macro is used to identify a user process.
  4258. ‘DEAD_PROCESS’
  4259. This macro is used to identify a terminated process.
  4260. The size of the ‘ut_line’, ‘ut_id’ and ‘ut_user’ arrays can be found
  4261. using the ‘sizeof’ operator.
  4262. -- Function: void setutxent (void)
  4263. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4264. lock fd | *Note POSIX Safety Concepts::.
  4265. This function is similar to ‘setutent’. In the GNU C Library it is
  4266. simply an alias for ‘setutent’.
  4267. -- Function: struct utmpx * getutxent (void)
  4268. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4269. heap lock | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4270. The ‘getutxent’ function is similar to ‘getutent’, but returns a
  4271. pointer to a ‘struct utmpx’ instead of ‘struct utmp’. In the GNU C
  4272. Library it simply is an alias for ‘getutent’.
  4273. -- Function: void endutxent (void)
  4274. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock | AC-Unsafe
  4275. lock | *Note POSIX Safety Concepts::.
  4276. This function is similar to ‘endutent’. In the GNU C Library it is
  4277. simply an alias for ‘endutent’.
  4278. -- Function: struct utmpx * getutxid (const struct utmpx *ID)
  4279. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4280. lock heap | AC-Unsafe lock mem fd | *Note POSIX Safety Concepts::.
  4281. This function is similar to ‘getutid’, but uses ‘struct utmpx’
  4282. instead of ‘struct utmp’. In the GNU C Library it is simply an
  4283. alias for ‘getutid’.
  4284. -- Function: struct utmpx * getutxline (const struct utmpx *LINE)
  4285. Preliminary: | MT-Unsafe init race:utent sig:ALRM timer | AS-Unsafe
  4286. heap lock | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4287. This function is similar to ‘getutid’, but uses ‘struct utmpx’
  4288. instead of ‘struct utmp’. In the GNU C Library it is simply an
  4289. alias for ‘getutline’.
  4290. -- Function: struct utmpx * pututxline (const struct utmpx *UTMP)
  4291. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4292. | AC-Unsafe lock fd | *Note POSIX Safety Concepts::.
  4293. The ‘pututxline’ function is functionally identical to ‘pututline’,
  4294. but uses ‘struct utmpx’ instead of ‘struct utmp’. In the GNU C
  4295. Library, ‘pututxline’ is simply an alias for ‘pututline’.
  4296. -- Function: int utmpxname (const char *FILE)
  4297. Preliminary: | MT-Unsafe race:utent | AS-Unsafe lock heap |
  4298. AC-Unsafe lock mem | *Note POSIX Safety Concepts::.
  4299. The ‘utmpxname’ function is functionally identical to ‘utmpname’.
  4300. In the GNU C Library, ‘utmpxname’ is simply an alias for
  4301. ‘utmpname’.
  4302. You can translate between a traditional ‘struct utmp’ and an XPG
  4303. ‘struct utmpx’ with the following functions. In the GNU C Library,
  4304. these functions are merely copies, since the two structures are
  4305. identical.
  4306. -- Function: int getutmp (const struct utmpx *UTMPX, struct utmp *UTMP)
  4307. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4308. Concepts::.
  4309. ‘getutmp’ copies the information, insofar as the structures are
  4310. compatible, from UTMPX to UTMP.
  4311. -- Function: int getutmpx (const struct utmp *UTMP, struct utmpx
  4312. *UTMPX)
  4313. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4314. Concepts::.
  4315. ‘getutmpx’ copies the information, insofar as the structures are
  4316. compatible, from UTMP to UTMPX.
  4317. 
  4318. File: libc.info, Node: Logging In and Out, Prev: XPG Functions, Up: User Accounting Database
  4319. 30.12.3 Logging In and Out
  4320. --------------------------
  4321. These functions, derived from BSD, are available in the separate
  4322. ‘libutil’ library, and declared in ‘utmp.h’.
  4323. Note that the ‘ut_user’ member of ‘struct utmp’ is called ‘ut_name’
  4324. in BSD. Therefore, ‘ut_name’ is defined as an alias for ‘ut_user’ in
  4325. ‘utmp.h’.
  4326. -- Function: int login_tty (int FILEDES)
  4327. Preliminary: | MT-Unsafe race:ttyname | AS-Unsafe heap lock |
  4328. AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4329. This function makes FILEDES the controlling terminal of the current
  4330. process, redirects standard input, standard output and standard
  4331. error output to this terminal, and closes FILEDES.
  4332. This function returns ‘0’ on successful completion, and ‘-1’ on
  4333. error.
  4334. -- Function: void login (const struct utmp *ENTRY)
  4335. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4336. heap | AC-Unsafe lock corrupt fd mem | *Note POSIX Safety
  4337. Concepts::.
  4338. The ‘login’ functions inserts an entry into the user accounting
  4339. database. The ‘ut_line’ member is set to the name of the terminal
  4340. on standard input. If standard input is not a terminal ‘login’
  4341. uses standard output or standard error output to determine the name
  4342. of the terminal. If ‘struct utmp’ has a ‘ut_type’ member, ‘login’
  4343. sets it to ‘USER_PROCESS’, and if there is an ‘ut_pid’ member, it
  4344. will be set to the process ID of the current process. The
  4345. remaining entries are copied from ENTRY.
  4346. A copy of the entry is written to the user accounting log file.
  4347. -- Function: int logout (const char *UT_LINE)
  4348. Preliminary: | MT-Unsafe race:utent sig:ALRM timer | AS-Unsafe lock
  4349. heap | AC-Unsafe lock fd mem | *Note POSIX Safety Concepts::.
  4350. This function modifies the user accounting database to indicate
  4351. that the user on UT_LINE has logged out.
  4352. The ‘logout’ function returns ‘1’ if the entry was successfully
  4353. written to the database, or ‘0’ on error.
  4354. -- Function: void logwtmp (const char *UT_LINE, const char *UT_NAME,
  4355. const char *UT_HOST)
  4356. Preliminary: | MT-Unsafe sig:ALRM timer | AS-Unsafe | AC-Unsafe fd
  4357. | *Note POSIX Safety Concepts::.
  4358. The ‘logwtmp’ function appends an entry to the user accounting log
  4359. file, for the current time and the information provided in the
  4360. UT_LINE, UT_NAME and UT_HOST arguments.
  4361. *Portability Note:* The BSD ‘struct utmp’ only has the ‘ut_line’,
  4362. ‘ut_name’, ‘ut_host’ and ‘ut_time’ members. Older systems do not even
  4363. have the ‘ut_host’ member.
  4364. 
  4365. File: libc.info, Node: User Database, Next: Group Database, Prev: User Accounting Database, Up: Users and Groups
  4366. 30.13 User Database
  4367. ===================
  4368. This section describes how to search and scan the database of registered
  4369. users. The database itself is kept in the file ‘/etc/passwd’ on most
  4370. systems, but on some systems a special network server gives access to
  4371. it.
  4372. * Menu:
  4373. * User Data Structure:: What each user record contains.
  4374. * Lookup User:: How to look for a particular user.
  4375. * Scanning All Users:: Scanning the list of all users, one by one.
  4376. * Writing a User Entry:: How a program can rewrite a user’s record.
  4377. 
  4378. File: libc.info, Node: User Data Structure, Next: Lookup User, Up: User Database
  4379. 30.13.1 The Data Structure that Describes a User
  4380. ------------------------------------------------
  4381. The functions and data structures for accessing the system user database
  4382. are declared in the header file ‘pwd.h’.
  4383. -- Data Type: struct passwd
  4384. The ‘passwd’ data structure is used to hold information about
  4385. entries in the system user data base. It has at least the
  4386. following members:
  4387. ‘char *pw_name’
  4388. The user’s login name.
  4389. ‘char *pw_passwd.’
  4390. The encrypted password string.
  4391. ‘uid_t pw_uid’
  4392. The user ID number.
  4393. ‘gid_t pw_gid’
  4394. The user’s default group ID number.
  4395. ‘char *pw_gecos’
  4396. A string typically containing the user’s real name, and
  4397. possibly other information such as a phone number.
  4398. ‘char *pw_dir’
  4399. The user’s home directory, or initial working directory. This
  4400. might be a null pointer, in which case the interpretation is
  4401. system-dependent.
  4402. ‘char *pw_shell’
  4403. The user’s default shell, or the initial program run when the
  4404. user logs in. This might be a null pointer, indicating that
  4405. the system default should be used.
  4406. 
  4407. File: libc.info, Node: Lookup User, Next: Scanning All Users, Prev: User Data Structure, Up: User Database
  4408. 30.13.2 Looking Up One User
  4409. ---------------------------
  4410. You can search the system user database for information about a specific
  4411. user using ‘getpwuid’ or ‘getpwnam’. These functions are declared in
  4412. ‘pwd.h’.
  4413. -- Function: struct passwd * getpwuid (uid_t UID)
  4414. Preliminary: | MT-Unsafe race:pwuid locale | AS-Unsafe dlopen
  4415. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4416. Safety Concepts::.
  4417. This function returns a pointer to a statically-allocated structure
  4418. containing information about the user whose user ID is UID. This
  4419. structure may be overwritten on subsequent calls to ‘getpwuid’.
  4420. A null pointer value indicates there is no user in the data base
  4421. with user ID UID.
  4422. -- Function: int getpwuid_r (uid_t UID, struct passwd *RESULT_BUF, char
  4423. *BUFFER, size_t BUFLEN, struct passwd **RESULT)
  4424. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4425. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4426. This function is similar to ‘getpwuid’ in that it returns
  4427. information about the user whose user ID is UID. However, it fills
  4428. the user supplied structure pointed to by RESULT_BUF with the
  4429. information instead of using a static buffer. The first BUFLEN
  4430. bytes of the additional buffer pointed to by BUFFER are used to
  4431. contain additional information, normally strings which are pointed
  4432. to by the elements of the result structure.
  4433. If a user with ID UID is found, the pointer returned in RESULT
  4434. points to the record which contains the wanted data (i.e., RESULT
  4435. contains the value RESULT_BUF). If no user is found or if an error
  4436. occurred, the pointer returned in RESULT is a null pointer. The
  4437. function returns zero or an error code. If the buffer BUFFER is
  4438. too small to contain all the needed information, the error code
  4439. ‘ERANGE’ is returned and ERRNO is set to ‘ERANGE’.
  4440. -- Function: struct passwd * getpwnam (const char *NAME)
  4441. Preliminary: | MT-Unsafe race:pwnam locale | AS-Unsafe dlopen
  4442. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4443. Safety Concepts::.
  4444. This function returns a pointer to a statically-allocated structure
  4445. containing information about the user whose user name is NAME.
  4446. This structure may be overwritten on subsequent calls to
  4447. ‘getpwnam’.
  4448. A null pointer return indicates there is no user named NAME.
  4449. -- Function: int getpwnam_r (const char *NAME, struct passwd
  4450. *RESULT_BUF, char *BUFFER, size_t BUFLEN, struct passwd
  4451. **RESULT)
  4452. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4453. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4454. This function is similar to ‘getpwnam’ in that it returns
  4455. information about the user whose user name is NAME. However, like
  4456. ‘getpwuid_r’, it fills the user supplied buffers in RESULT_BUF and
  4457. BUFFER with the information instead of using a static buffer.
  4458. The return values are the same as for ‘getpwuid_r’.
  4459. 
  4460. File: libc.info, Node: Scanning All Users, Next: Writing a User Entry, Prev: Lookup User, Up: User Database
  4461. 30.13.3 Scanning the List of All Users
  4462. --------------------------------------
  4463. This section explains how a program can read the list of all users in
  4464. the system, one user at a time. The functions described here are
  4465. declared in ‘pwd.h’.
  4466. You can use the ‘fgetpwent’ function to read user entries from a
  4467. particular file.
  4468. -- Function: struct passwd * fgetpwent (FILE *STREAM)
  4469. Preliminary: | MT-Unsafe race:fpwent | AS-Unsafe corrupt lock |
  4470. AC-Unsafe corrupt lock | *Note POSIX Safety Concepts::.
  4471. This function reads the next user entry from STREAM and returns a
  4472. pointer to the entry. The structure is statically allocated and is
  4473. rewritten on subsequent calls to ‘fgetpwent’. You must copy the
  4474. contents of the structure if you wish to save the information.
  4475. The stream must correspond to a file in the same format as the
  4476. standard password database file.
  4477. -- Function: int fgetpwent_r (FILE *STREAM, struct passwd *RESULT_BUF,
  4478. char *BUFFER, size_t BUFLEN, struct passwd **RESULT)
  4479. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  4480. | *Note POSIX Safety Concepts::.
  4481. This function is similar to ‘fgetpwent’ in that it reads the next
  4482. user entry from STREAM. But the result is returned in the
  4483. structure pointed to by RESULT_BUF. The first BUFLEN bytes of the
  4484. additional buffer pointed to by BUFFER are used to contain
  4485. additional information, normally strings which are pointed to by
  4486. the elements of the result structure.
  4487. The stream must correspond to a file in the same format as the
  4488. standard password database file.
  4489. If the function returns zero RESULT points to the structure with
  4490. the wanted data (normally this is in RESULT_BUF). If errors
  4491. occurred the return value is nonzero and RESULT contains a null
  4492. pointer.
  4493. The way to scan all the entries in the user database is with
  4494. ‘setpwent’, ‘getpwent’, and ‘endpwent’.
  4495. -- Function: void setpwent (void)
  4496. Preliminary: | MT-Unsafe race:pwent locale | AS-Unsafe dlopen
  4497. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4498. Safety Concepts::.
  4499. This function initializes a stream which ‘getpwent’ and
  4500. ‘getpwent_r’ use to read the user database.
  4501. -- Function: struct passwd * getpwent (void)
  4502. Preliminary: | MT-Unsafe race:pwent race:pwentbuf locale |
  4503. AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem |
  4504. *Note POSIX Safety Concepts::.
  4505. The ‘getpwent’ function reads the next entry from the stream
  4506. initialized by ‘setpwent’. It returns a pointer to the entry. The
  4507. structure is statically allocated and is rewritten on subsequent
  4508. calls to ‘getpwent’. You must copy the contents of the structure
  4509. if you wish to save the information.
  4510. A null pointer is returned when no more entries are available.
  4511. -- Function: int getpwent_r (struct passwd *RESULT_BUF, char *BUFFER,
  4512. size_t BUFLEN, struct passwd **RESULT)
  4513. Preliminary: | MT-Unsafe race:pwent locale | AS-Unsafe dlopen
  4514. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4515. Safety Concepts::.
  4516. This function is similar to ‘getpwent’ in that it returns the next
  4517. entry from the stream initialized by ‘setpwent’. Like
  4518. ‘fgetpwent_r’, it uses the user-supplied buffers in RESULT_BUF and
  4519. BUFFER to return the information requested.
  4520. The return values are the same as for ‘fgetpwent_r’.
  4521. -- Function: void endpwent (void)
  4522. Preliminary: | MT-Unsafe race:pwent locale | AS-Unsafe dlopen
  4523. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4524. Safety Concepts::.
  4525. This function closes the internal stream used by ‘getpwent’ or
  4526. ‘getpwent_r’.
  4527. 
  4528. File: libc.info, Node: Writing a User Entry, Prev: Scanning All Users, Up: User Database
  4529. 30.13.4 Writing a User Entry
  4530. ----------------------------
  4531. -- Function: int putpwent (const struct passwd *P, FILE *STREAM)
  4532. Preliminary: | MT-Safe locale | AS-Unsafe corrupt | AC-Unsafe lock
  4533. corrupt | *Note POSIX Safety Concepts::.
  4534. This function writes the user entry ‘*P’ to the stream STREAM, in
  4535. the format used for the standard user database file. The return
  4536. value is zero on success and nonzero on failure.
  4537. This function exists for compatibility with SVID. We recommend that
  4538. you avoid using it, because it makes sense only on the assumption
  4539. that the ‘struct passwd’ structure has no members except the
  4540. standard ones; on a system which merges the traditional Unix data
  4541. base with other extended information about users, adding an entry
  4542. using this function would inevitably leave out much of the
  4543. important information.
  4544. The group and user ID fields are left empty if the group or user
  4545. name starts with a - or +.
  4546. The function ‘putpwent’ is declared in ‘pwd.h’.
  4547. 
  4548. File: libc.info, Node: Group Database, Next: Database Example, Prev: User Database, Up: Users and Groups
  4549. 30.14 Group Database
  4550. ====================
  4551. This section describes how to search and scan the database of registered
  4552. groups. The database itself is kept in the file ‘/etc/group’ on most
  4553. systems, but on some systems a special network service provides access
  4554. to it.
  4555. * Menu:
  4556. * Group Data Structure:: What each group record contains.
  4557. * Lookup Group:: How to look for a particular group.
  4558. * Scanning All Groups:: Scanning the list of all groups.
  4559. 
  4560. File: libc.info, Node: Group Data Structure, Next: Lookup Group, Up: Group Database
  4561. 30.14.1 The Data Structure for a Group
  4562. --------------------------------------
  4563. The functions and data structures for accessing the system group
  4564. database are declared in the header file ‘grp.h’.
  4565. -- Data Type: struct group
  4566. The ‘group’ structure is used to hold information about an entry in
  4567. the system group database. It has at least the following members:
  4568. ‘char *gr_name’
  4569. The name of the group.
  4570. ‘gid_t gr_gid’
  4571. The group ID of the group.
  4572. ‘char **gr_mem’
  4573. A vector of pointers to the names of users in the group. Each
  4574. user name is a null-terminated string, and the vector itself
  4575. is terminated by a null pointer.
  4576. 
  4577. File: libc.info, Node: Lookup Group, Next: Scanning All Groups, Prev: Group Data Structure, Up: Group Database
  4578. 30.14.2 Looking Up One Group
  4579. ----------------------------
  4580. You can search the group database for information about a specific group
  4581. using ‘getgrgid’ or ‘getgrnam’. These functions are declared in
  4582. ‘grp.h’.
  4583. -- Function: struct group * getgrgid (gid_t GID)
  4584. Preliminary: | MT-Unsafe race:grgid locale | AS-Unsafe dlopen
  4585. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4586. Safety Concepts::.
  4587. This function returns a pointer to a statically-allocated structure
  4588. containing information about the group whose group ID is GID. This
  4589. structure may be overwritten by subsequent calls to ‘getgrgid’.
  4590. A null pointer indicates there is no group with ID GID.
  4591. -- Function: int getgrgid_r (gid_t GID, struct group *RESULT_BUF, char
  4592. *BUFFER, size_t BUFLEN, struct group **RESULT)
  4593. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4594. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4595. This function is similar to ‘getgrgid’ in that it returns
  4596. information about the group whose group ID is GID. However, it
  4597. fills the user supplied structure pointed to by RESULT_BUF with the
  4598. information instead of using a static buffer. The first BUFLEN
  4599. bytes of the additional buffer pointed to by BUFFER are used to
  4600. contain additional information, normally strings which are pointed
  4601. to by the elements of the result structure.
  4602. If a group with ID GID is found, the pointer returned in RESULT
  4603. points to the record which contains the wanted data (i.e., RESULT
  4604. contains the value RESULT_BUF). If no group is found or if an
  4605. error occurred, the pointer returned in RESULT is a null pointer.
  4606. The function returns zero or an error code. If the buffer BUFFER
  4607. is too small to contain all the needed information, the error code
  4608. ‘ERANGE’ is returned and ERRNO is set to ‘ERANGE’.
  4609. -- Function: struct group * getgrnam (const char *NAME)
  4610. Preliminary: | MT-Unsafe race:grnam locale | AS-Unsafe dlopen
  4611. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4612. Safety Concepts::.
  4613. This function returns a pointer to a statically-allocated structure
  4614. containing information about the group whose group name is NAME.
  4615. This structure may be overwritten by subsequent calls to
  4616. ‘getgrnam’.
  4617. A null pointer indicates there is no group named NAME.
  4618. -- Function: int getgrnam_r (const char *NAME, struct group
  4619. *RESULT_BUF, char *BUFFER, size_t BUFLEN, struct group
  4620. **RESULT)
  4621. Preliminary: | MT-Safe locale | AS-Unsafe dlopen plugin heap lock |
  4622. AC-Unsafe corrupt lock fd mem | *Note POSIX Safety Concepts::.
  4623. This function is similar to ‘getgrnam’ in that it returns
  4624. information about the group whose group name is NAME. Like
  4625. ‘getgrgid_r’, it uses the user supplied buffers in RESULT_BUF and
  4626. BUFFER, not a static buffer.
  4627. The return values are the same as for ‘getgrgid_r’.
  4628. 
  4629. File: libc.info, Node: Scanning All Groups, Prev: Lookup Group, Up: Group Database
  4630. 30.14.3 Scanning the List of All Groups
  4631. ---------------------------------------
  4632. This section explains how a program can read the list of all groups in
  4633. the system, one group at a time. The functions described here are
  4634. declared in ‘grp.h’.
  4635. You can use the ‘fgetgrent’ function to read group entries from a
  4636. particular file.
  4637. -- Function: struct group * fgetgrent (FILE *STREAM)
  4638. Preliminary: | MT-Unsafe race:fgrent | AS-Unsafe corrupt lock |
  4639. AC-Unsafe corrupt lock | *Note POSIX Safety Concepts::.
  4640. The ‘fgetgrent’ function reads the next entry from STREAM. It
  4641. returns a pointer to the entry. The structure is statically
  4642. allocated and is overwritten on subsequent calls to ‘fgetgrent’.
  4643. You must copy the contents of the structure if you wish to save the
  4644. information.
  4645. The stream must correspond to a file in the same format as the
  4646. standard group database file.
  4647. -- Function: int fgetgrent_r (FILE *STREAM, struct group *RESULT_BUF,
  4648. char *BUFFER, size_t BUFLEN, struct group **RESULT)
  4649. Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe corrupt lock
  4650. | *Note POSIX Safety Concepts::.
  4651. This function is similar to ‘fgetgrent’ in that it reads the next
  4652. user entry from STREAM. But the result is returned in the
  4653. structure pointed to by RESULT_BUF. The first BUFLEN bytes of the
  4654. additional buffer pointed to by BUFFER are used to contain
  4655. additional information, normally strings which are pointed to by
  4656. the elements of the result structure.
  4657. This stream must correspond to a file in the same format as the
  4658. standard group database file.
  4659. If the function returns zero RESULT points to the structure with
  4660. the wanted data (normally this is in RESULT_BUF). If errors
  4661. occurred the return value is non-zero and RESULT contains a null
  4662. pointer.
  4663. The way to scan all the entries in the group database is with
  4664. ‘setgrent’, ‘getgrent’, and ‘endgrent’.
  4665. -- Function: void setgrent (void)
  4666. Preliminary: | MT-Unsafe race:grent locale | AS-Unsafe dlopen
  4667. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4668. Safety Concepts::.
  4669. This function initializes a stream for reading from the group data
  4670. base. You use this stream by calling ‘getgrent’ or ‘getgrent_r’.
  4671. -- Function: struct group * getgrent (void)
  4672. Preliminary: | MT-Unsafe race:grent race:grentbuf locale |
  4673. AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem |
  4674. *Note POSIX Safety Concepts::.
  4675. The ‘getgrent’ function reads the next entry from the stream
  4676. initialized by ‘setgrent’. It returns a pointer to the entry. The
  4677. structure is statically allocated and is overwritten on subsequent
  4678. calls to ‘getgrent’. You must copy the contents of the structure
  4679. if you wish to save the information.
  4680. -- Function: int getgrent_r (struct group *RESULT_BUF, char *BUFFER,
  4681. size_t BUFLEN, struct group **RESULT)
  4682. Preliminary: | MT-Unsafe race:grent locale | AS-Unsafe dlopen
  4683. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4684. Safety Concepts::.
  4685. This function is similar to ‘getgrent’ in that it returns the next
  4686. entry from the stream initialized by ‘setgrent’. Like
  4687. ‘fgetgrent_r’, it places the result in user-supplied buffers
  4688. pointed to by RESULT_BUF and BUFFER.
  4689. If the function returns zero RESULT contains a pointer to the data
  4690. (normally equal to RESULT_BUF). If errors occurred the return
  4691. value is non-zero and RESULT contains a null pointer.
  4692. -- Function: void endgrent (void)
  4693. Preliminary: | MT-Unsafe race:grent locale | AS-Unsafe dlopen
  4694. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4695. Safety Concepts::.
  4696. This function closes the internal stream used by ‘getgrent’ or
  4697. ‘getgrent_r’.
  4698. 
  4699. File: libc.info, Node: Database Example, Next: Netgroup Database, Prev: Group Database, Up: Users and Groups
  4700. 30.15 User and Group Database Example
  4701. =====================================
  4702. Here is an example program showing the use of the system database
  4703. inquiry functions. The program prints some information about the user
  4704. running the program.
  4705. #include <grp.h>
  4706. #include <pwd.h>
  4707. #include <sys/types.h>
  4708. #include <unistd.h>
  4709. #include <stdlib.h>
  4710. int
  4711. main (void)
  4712. {
  4713. uid_t me;
  4714. struct passwd *my_passwd;
  4715. struct group *my_group;
  4716. char **members;
  4717. /* Get information about the user ID. */
  4718. me = getuid ();
  4719. my_passwd = getpwuid (me);
  4720. if (!my_passwd)
  4721. {
  4722. printf ("Couldn't find out about user %d.\n", (int) me);
  4723. exit (EXIT_FAILURE);
  4724. }
  4725. /* Print the information. */
  4726. printf ("I am %s.\n", my_passwd->pw_gecos);
  4727. printf ("My login name is %s.\n", my_passwd->pw_name);
  4728. printf ("My uid is %d.\n", (int) (my_passwd->pw_uid));
  4729. printf ("My home directory is %s.\n", my_passwd->pw_dir);
  4730. printf ("My default shell is %s.\n", my_passwd->pw_shell);
  4731. /* Get information about the default group ID. */
  4732. my_group = getgrgid (my_passwd->pw_gid);
  4733. if (!my_group)
  4734. {
  4735. printf ("Couldn't find out about group %d.\n",
  4736. (int) my_passwd->pw_gid);
  4737. exit (EXIT_FAILURE);
  4738. }
  4739. /* Print the information. */
  4740. printf ("My default group is %s (%d).\n",
  4741. my_group->gr_name, (int) (my_passwd->pw_gid));
  4742. printf ("The members of this group are:\n");
  4743. members = my_group->gr_mem;
  4744. while (*members)
  4745. {
  4746. printf (" %s\n", *(members));
  4747. members++;
  4748. }
  4749. return EXIT_SUCCESS;
  4750. }
  4751. Here is some output from this program:
  4752. I am Throckmorton Snurd.
  4753. My login name is snurd.
  4754. My uid is 31093.
  4755. My home directory is /home/fsg/snurd.
  4756. My default shell is /bin/sh.
  4757. My default group is guest (12).
  4758. The members of this group are:
  4759. friedman
  4760. tami
  4761. 
  4762. File: libc.info, Node: Netgroup Database, Prev: Database Example, Up: Users and Groups
  4763. 30.16 Netgroup Database
  4764. =======================
  4765. * Menu:
  4766. * Netgroup Data:: Data in the Netgroup database and where
  4767. it comes from.
  4768. * Lookup Netgroup:: How to look for a particular netgroup.
  4769. * Netgroup Membership:: How to test for netgroup membership.
  4770. 
  4771. File: libc.info, Node: Netgroup Data, Next: Lookup Netgroup, Up: Netgroup Database
  4772. 30.16.1 Netgroup Data
  4773. ---------------------
  4774. Sometimes it is useful to group users according to other criteria (*note
  4775. Group Database::). E.g., it is useful to associate a certain group of
  4776. users with a certain machine. On the other hand grouping of host names
  4777. is not supported so far.
  4778. In Sun Microsystems’ SunOS appeared a new kind of database, the
  4779. netgroup database. It allows grouping hosts, users, and domains freely,
  4780. giving them individual names. To be more concrete, a netgroup is a list
  4781. of triples consisting of a host name, a user name, and a domain name
  4782. where any of the entries can be a wildcard entry matching all inputs. A
  4783. last possibility is that names of other netgroups can also be given in
  4784. the list specifying a netgroup. So one can construct arbitrary
  4785. hierarchies without loops.
  4786. Sun’s implementation allows netgroups only for the ‘nis’ or ‘nisplus’
  4787. service, *note Services in the NSS configuration::. The implementation
  4788. in the GNU C Library has no such restriction. An entry in either of the
  4789. input services must have the following form:
  4790. GROUPNAME ( GROUPNAME | (HOSTNAME,USERNAME,domainname) )+
  4791. Any of the fields in the triple can be empty which means anything
  4792. matches. While describing the functions we will see that the opposite
  4793. case is useful as well. I.e., there may be entries which will not match
  4794. any input. For entries like this, a name consisting of the single
  4795. character ‘-’ shall be used.
  4796. 
  4797. File: libc.info, Node: Lookup Netgroup, Next: Netgroup Membership, Prev: Netgroup Data, Up: Netgroup Database
  4798. 30.16.2 Looking up one Netgroup
  4799. -------------------------------
  4800. The lookup functions for netgroups are a bit different than all other
  4801. system database handling functions. Since a single netgroup can contain
  4802. many entries a two-step process is needed. First a single netgroup is
  4803. selected and then one can iterate over all entries in this netgroup.
  4804. These functions are declared in ‘netdb.h’.
  4805. -- Function: int setnetgrent (const char *NETGROUP)
  4806. Preliminary: | MT-Unsafe race:netgrent locale | AS-Unsafe dlopen
  4807. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4808. Safety Concepts::.
  4809. A call to this function initializes the internal state of the
  4810. library to allow following calls of ‘getnetgrent’ to iterate over
  4811. all entries in the netgroup with name NETGROUP.
  4812. When the call is successful (i.e., when a netgroup with this name
  4813. exists) the return value is ‘1’. When the return value is ‘0’ no
  4814. netgroup of this name is known or some other error occurred.
  4815. It is important to remember that there is only one single state for
  4816. iterating the netgroups. Even if the programmer uses the
  4817. ‘getnetgrent_r’ function the result is not really reentrant since always
  4818. only one single netgroup at a time can be processed. If the program
  4819. needs to process more than one netgroup simultaneously she must protect
  4820. this by using external locking. This problem was introduced in the
  4821. original netgroups implementation in SunOS and since we must stay
  4822. compatible it is not possible to change this.
  4823. Some other functions also use the netgroups state. Currently these
  4824. are the ‘innetgr’ function and parts of the implementation of the
  4825. ‘compat’ service part of the NSS implementation.
  4826. -- Function: int getnetgrent (char **HOSTP, char **USERP, char
  4827. **DOMAINP)
  4828. Preliminary: | MT-Unsafe race:netgrent race:netgrentbuf locale |
  4829. AS-Unsafe dlopen plugin heap lock | AC-Unsafe corrupt lock fd mem |
  4830. *Note POSIX Safety Concepts::.
  4831. This function returns the next unprocessed entry of the currently
  4832. selected netgroup. The string pointers, in which addresses are
  4833. passed in the arguments HOSTP, USERP, and DOMAINP, will contain
  4834. after a successful call pointers to appropriate strings. If the
  4835. string in the next entry is empty the pointer has the value ‘NULL’.
  4836. The returned string pointers are only valid if none of the netgroup
  4837. related functions are called.
  4838. The return value is ‘1’ if the next entry was successfully read. A
  4839. value of ‘0’ means no further entries exist or internal errors
  4840. occurred.
  4841. -- Function: int getnetgrent_r (char **HOSTP, char **USERP, char
  4842. **DOMAINP, char *BUFFER, size_t BUFLEN)
  4843. Preliminary: | MT-Unsafe race:netgrent locale | AS-Unsafe dlopen
  4844. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4845. Safety Concepts::.
  4846. This function is similar to ‘getnetgrent’ with only one exception:
  4847. the strings the three string pointers HOSTP, USERP, and DOMAINP
  4848. point to, are placed in the buffer of BUFLEN bytes starting at
  4849. BUFFER. This means the returned values are valid even after other
  4850. netgroup related functions are called.
  4851. The return value is ‘1’ if the next entry was successfully read and
  4852. the buffer contains enough room to place the strings in it. ‘0’ is
  4853. returned in case no more entries are found, the buffer is too
  4854. small, or internal errors occurred.
  4855. This function is a GNU extension. The original implementation in
  4856. the SunOS libc does not provide this function.
  4857. -- Function: void endnetgrent (void)
  4858. Preliminary: | MT-Unsafe race:netgrent | AS-Unsafe dlopen plugin
  4859. heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX Safety
  4860. Concepts::.
  4861. This function frees all buffers which were allocated to process the
  4862. last selected netgroup. As a result all string pointers returned
  4863. by calls to ‘getnetgrent’ are invalid afterwards.
  4864. 
  4865. File: libc.info, Node: Netgroup Membership, Prev: Lookup Netgroup, Up: Netgroup Database
  4866. 30.16.3 Testing for Netgroup Membership
  4867. ---------------------------------------
  4868. It is often not necessary to scan the whole netgroup since often the
  4869. only interesting question is whether a given entry is part of the
  4870. selected netgroup.
  4871. -- Function: int innetgr (const char *NETGROUP, const char *HOST, const
  4872. char *USER, const char *DOMAIN)
  4873. Preliminary: | MT-Unsafe race:netgrent locale | AS-Unsafe dlopen
  4874. plugin heap lock | AC-Unsafe corrupt lock fd mem | *Note POSIX
  4875. Safety Concepts::.
  4876. This function tests whether the triple specified by the parameters
  4877. HOST, USER, and DOMAIN is part of the netgroup NETGROUP. Using
  4878. this function has the advantage that
  4879. 1. no other netgroup function can use the global netgroup state
  4880. since internal locking is used and
  4881. 2. the function is implemented more efficiently than successive
  4882. calls to the other ‘set’/‘get’/‘endnetgrent’ functions.
  4883. Any of the pointers HOST, USER, or DOMAIN can be ‘NULL’ which means
  4884. any value is accepted in this position. This is also true for the
  4885. name ‘-’ which should not match any other string otherwise.
  4886. The return value is ‘1’ if an entry matching the given triple is
  4887. found in the netgroup. The return value is ‘0’ if the netgroup
  4888. itself is not found, the netgroup does not contain the triple or
  4889. internal errors occurred.
  4890. 
  4891. File: libc.info, Node: System Management, Next: System Configuration, Prev: Users and Groups, Up: Top
  4892. 31 System Management
  4893. ********************
  4894. This chapter describes facilities for controlling the system that
  4895. underlies a process (including the operating system and hardware) and
  4896. for getting information about it. Anyone can generally use the
  4897. informational facilities, but usually only a properly privileged process
  4898. can make changes.
  4899. * Menu:
  4900. * Host Identification:: Determining the name of the machine.
  4901. * Platform Type:: Determining operating system and basic
  4902. machine type
  4903. * Filesystem Handling:: Controlling/querying mounts
  4904. * System Parameters:: Getting and setting various system parameters
  4905. To get information on parameters of the system that are built into
  4906. the system, such as the maximum length of a filename, *note System
  4907. Configuration::.
  4908. 
  4909. File: libc.info, Node: Host Identification, Next: Platform Type, Up: System Management
  4910. 31.1 Host Identification
  4911. ========================
  4912. This section explains how to identify the particular system on which
  4913. your program is running. First, let’s review the various ways computer
  4914. systems are named, which is a little complicated because of the history
  4915. of the development of the Internet.
  4916. Every Unix system (also known as a host) has a host name, whether
  4917. it’s connected to a network or not. In its simplest form, as used
  4918. before computer networks were an issue, it’s just a word like ‘chicken’.
  4919. But any system attached to the Internet or any network like it
  4920. conforms to a more rigorous naming convention as part of the Domain Name
  4921. System (DNS). In the DNS, every host name is composed of two parts:
  4922. 1. hostname
  4923. 2. domain name
  4924. You will note that “hostname” looks a lot like “host name”, but is
  4925. not the same thing, and that people often incorrectly refer to entire
  4926. host names as “domain names.”
  4927. In the DNS, the full host name is properly called the FQDN (Fully
  4928. Qualified Domain Name) and consists of the hostname, then a period, then
  4929. the domain name. The domain name itself usually has multiple components
  4930. separated by periods. So for example, a system’s hostname may be
  4931. ‘chicken’ and its domain name might be ‘ai.mit.edu’, so its FQDN (which
  4932. is its host name) is ‘chicken.ai.mit.edu’.
  4933. Adding to the confusion, though, is that the DNS is not the only name
  4934. space in which a computer needs to be known. Another name space is the
  4935. NIS (aka YP) name space. For NIS purposes, there is another domain
  4936. name, which is called the NIS domain name or the YP domain name. It
  4937. need not have anything to do with the DNS domain name.
  4938. Confusing things even more is the fact that in the DNS, it is
  4939. possible for multiple FQDNs to refer to the same system. However, there
  4940. is always exactly one of them that is the true host name, and it is
  4941. called the canonical FQDN.
  4942. In some contexts, the host name is called a “node name.”
  4943. For more information on DNS host naming, see *note Host Names::.
  4944. Prototypes for these functions appear in ‘unistd.h’.
  4945. The programs ‘hostname’, ‘hostid’, and ‘domainname’ work by calling
  4946. these functions.
  4947. -- Function: int gethostname (char *NAME, size_t SIZE)
  4948. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4949. Concepts::.
  4950. This function returns the host name of the system on which it is
  4951. called, in the array NAME. The SIZE argument specifies the size of
  4952. this array, in bytes. Note that this is _not_ the DNS hostname.
  4953. If the system participates in the DNS, this is the FQDN (see
  4954. above).
  4955. The return value is ‘0’ on success and ‘-1’ on failure. In the GNU
  4956. C Library, ‘gethostname’ fails if SIZE is not large enough; then
  4957. you can try again with a larger array. The following ‘errno’ error
  4958. condition is defined for this function:
  4959. ‘ENAMETOOLONG’
  4960. The SIZE argument is less than the size of the host name plus
  4961. one.
  4962. On some systems, there is a symbol for the maximum possible host
  4963. name length: ‘MAXHOSTNAMELEN’. It is defined in ‘sys/param.h’.
  4964. But you can’t count on this to exist, so it is cleaner to handle
  4965. failure and try again.
  4966. ‘gethostname’ stores the beginning of the host name in NAME even if
  4967. the host name won’t entirely fit. For some purposes, a truncated
  4968. host name is good enough. If it is, you can ignore the error code.
  4969. -- Function: int sethostname (const char *NAME, size_t LENGTH)
  4970. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4971. Concepts::.
  4972. The ‘sethostname’ function sets the host name of the system that
  4973. calls it to NAME, a string with length LENGTH. Only privileged
  4974. processes are permitted to do this.
  4975. Usually ‘sethostname’ gets called just once, at system boot time.
  4976. Often, the program that calls it sets it to the value it finds in
  4977. the file ‘/etc/hostname’.
  4978. Be sure to set the host name to the full host name, not just the
  4979. DNS hostname (see above).
  4980. The return value is ‘0’ on success and ‘-1’ on failure. The
  4981. following ‘errno’ error condition is defined for this function:
  4982. ‘EPERM’
  4983. This process cannot set the host name because it is not
  4984. privileged.
  4985. -- Function: int getdomainnname (char *NAME, size_t LENGTH)
  4986. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4987. Concepts::.
  4988. ‘getdomainname’ returns the NIS (aka YP) domain name of the system
  4989. on which it is called. Note that this is not the more popular DNS
  4990. domain name. Get that with ‘gethostname’.
  4991. The specifics of this function are analogous to ‘gethostname’,
  4992. above.
  4993. -- Function: int setdomainname (const char *NAME, size_t LENGTH)
  4994. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  4995. Concepts::.
  4996. ‘setdomainname’ sets the NIS (aka YP) domain name of the system on
  4997. which it is called. Note that this is not the more popular DNS
  4998. domain name. Set that with ‘sethostname’.
  4999. The specifics of this function are analogous to ‘sethostname’,
  5000. above.
  5001. -- Function: long int gethostid (void)
  5002. Preliminary: | MT-Safe hostid env locale | AS-Unsafe dlopen plugin
  5003. corrupt heap lock | AC-Unsafe lock corrupt mem fd | *Note POSIX
  5004. Safety Concepts::.
  5005. This function returns the “host ID” of the machine the program is
  5006. running on. By convention, this is usually the primary Internet IP
  5007. address of that machine, converted to a ‘long int’. However, on
  5008. some systems it is a meaningless but unique number which is
  5009. hard-coded for each machine.
  5010. This is not widely used. It arose in BSD 4.2, but was dropped in
  5011. BSD 4.4. It is not required by POSIX.
  5012. The proper way to query the IP address is to use ‘gethostbyname’ on
  5013. the results of ‘gethostname’. For more information on IP
  5014. addresses, *Note Host Addresses::.
  5015. -- Function: int sethostid (long int ID)
  5016. Preliminary: | MT-Unsafe const:hostid | AS-Unsafe | AC-Unsafe
  5017. corrupt fd | *Note POSIX Safety Concepts::.
  5018. The ‘sethostid’ function sets the “host ID” of the host machine to
  5019. ID. Only privileged processes are permitted to do this. Usually
  5020. it happens just once, at system boot time.
  5021. The proper way to establish the primary IP address of a system is
  5022. to configure the IP address resolver to associate that IP address
  5023. with the system’s host name as returned by ‘gethostname’. For
  5024. example, put a record for the system in ‘/etc/hosts’.
  5025. See ‘gethostid’ above for more information on host ids.
  5026. The return value is ‘0’ on success and ‘-1’ on failure. The
  5027. following ‘errno’ error conditions are defined for this function:
  5028. ‘EPERM’
  5029. This process cannot set the host name because it is not
  5030. privileged.
  5031. ‘ENOSYS’
  5032. The operating system does not support setting the host ID. On
  5033. some systems, the host ID is a meaningless but unique number
  5034. hard-coded for each machine.
  5035. 
  5036. File: libc.info, Node: Platform Type, Next: Filesystem Handling, Prev: Host Identification, Up: System Management
  5037. 31.2 Platform Type Identification
  5038. =================================
  5039. You can use the ‘uname’ function to find out some information about the
  5040. type of computer your program is running on. This function and the
  5041. associated data type are declared in the header file ‘sys/utsname.h’.
  5042. As a bonus, ‘uname’ also gives some information identifying the
  5043. particular system your program is running on. This is the same
  5044. information which you can get with functions targeted to this purpose
  5045. described in *note Host Identification::.
  5046. -- Data Type: struct utsname
  5047. The ‘utsname’ structure is used to hold information returned by the
  5048. ‘uname’ function. It has the following members:
  5049. ‘char sysname[]’
  5050. This is the name of the operating system in use.
  5051. ‘char release[]’
  5052. This is the current release level of the operating system
  5053. implementation.
  5054. ‘char version[]’
  5055. This is the current version level within the release of the
  5056. operating system.
  5057. ‘char machine[]’
  5058. This is a description of the type of hardware that is in use.
  5059. Some systems provide a mechanism to interrogate the kernel
  5060. directly for this information. On systems without such a
  5061. mechanism, the GNU C Library fills in this field based on the
  5062. configuration name that was specified when building and
  5063. installing the library.
  5064. GNU uses a three-part name to describe a system configuration;
  5065. the three parts are CPU, MANUFACTURER and SYSTEM-TYPE, and
  5066. they are separated with dashes. Any possible combination of
  5067. three names is potentially meaningful, but most such
  5068. combinations are meaningless in practice and even the
  5069. meaningful ones are not necessarily supported by any
  5070. particular GNU program.
  5071. Since the value in ‘machine’ is supposed to describe just the
  5072. hardware, it consists of the first two parts of the
  5073. configuration name: ‘CPU-MANUFACTURER’. For example, it might
  5074. be one of these:
  5075. ‘"sparc-sun"’, ‘"i386-ANYTHING"’, ‘"m68k-hp"’,
  5076. ‘"m68k-sony"’, ‘"m68k-sun"’, ‘"mips-dec"’
  5077. ‘char nodename[]’
  5078. This is the host name of this particular computer. In the GNU
  5079. C Library, the value is the same as that returned by
  5080. ‘gethostname’; see *note Host Identification::.
  5081. ‘gethostname’ is implemented with a call to ‘uname’.
  5082. ‘char domainname[]’
  5083. This is the NIS or YP domain name. It is the same value
  5084. returned by ‘getdomainname’; see *note Host Identification::.
  5085. This element is a relatively recent invention and use of it is
  5086. not as portable as use of the rest of the structure.
  5087. -- Function: int uname (struct utsname *INFO)
  5088. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5089. Concepts::.
  5090. The ‘uname’ function fills in the structure pointed to by INFO with
  5091. information about the operating system and host machine. A
  5092. non-negative return value indicates that the data was successfully
  5093. stored.
  5094. ‘-1’ as the return value indicates an error. The only error
  5095. possible is ‘EFAULT’, which we normally don’t mention as it is
  5096. always a possibility.
  5097. 
  5098. File: libc.info, Node: Filesystem Handling, Next: System Parameters, Prev: Platform Type, Up: System Management
  5099. 31.3 Controlling and Querying Mounts
  5100. ====================================
  5101. All files are in filesystems, and before you can access any file, its
  5102. filesystem must be mounted. Because of Unix’s concept of _Everything is
  5103. a file_, mounting of filesystems is central to doing almost anything.
  5104. This section explains how to find out what filesystems are currently
  5105. mounted and what filesystems are available for mounting, and how to
  5106. change what is mounted.
  5107. The classic filesystem is the contents of a disk drive. The concept
  5108. is considerably more abstract, though, and lots of things other than
  5109. disk drives can be mounted.
  5110. Some block devices don’t correspond to traditional devices like disk
  5111. drives. For example, a loop device is a block device whose driver uses
  5112. a regular file in another filesystem as its medium. So if that regular
  5113. file contains appropriate data for a filesystem, you can by mounting the
  5114. loop device essentially mount a regular file.
  5115. Some filesystems aren’t based on a device of any kind. The “proc”
  5116. filesystem, for example, contains files whose data is made up by the
  5117. filesystem driver on the fly whenever you ask for it. And when you
  5118. write to it, the data you write causes changes in the system. No data
  5119. gets stored.
  5120. * Menu:
  5121. * Mount Information:: What is or could be mounted?
  5122. * Mount-Unmount-Remount:: Controlling what is mounted and how
  5123. 
  5124. File: libc.info, Node: Mount Information, Next: Mount-Unmount-Remount, Up: Filesystem Handling
  5125. 31.3.1 Mount Information
  5126. ------------------------
  5127. For some programs it is desirable and necessary to access information
  5128. about whether a certain filesystem is mounted and, if it is, where, or
  5129. simply to get lists of all the available filesystems. The GNU C Library
  5130. provides some functions to retrieve this information portably.
  5131. Traditionally Unix systems have a file named ‘/etc/fstab’ which
  5132. describes all possibly mounted filesystems. The ‘mount’ program uses
  5133. this file to mount at startup time of the system all the necessary
  5134. filesystems. The information about all the filesystems actually mounted
  5135. is normally kept in a file named either ‘/var/run/mtab’ or ‘/etc/mtab’.
  5136. Both files share the same syntax and it is crucial that this syntax is
  5137. followed all the time. Therefore it is best to never directly write to
  5138. the files. The functions described in this section can do this and they
  5139. also provide the functionality to convert the external textual
  5140. representation to the internal representation.
  5141. Note that the ‘fstab’ and ‘mtab’ files are maintained on a system by
  5142. _convention_. It is possible for the files not to exist or not to be
  5143. consistent with what is really mounted or available to mount, if the
  5144. system’s administration policy allows it. But programs that mount and
  5145. unmount filesystems typically maintain and use these files as described
  5146. herein.
  5147. The filenames given above should never be used directly. The
  5148. portable way to handle these files is to use the macros ‘_PATH_FSTAB’,
  5149. defined in ‘fstab.h’, or ‘_PATH_MNTTAB’, defined in ‘mntent.h’ and
  5150. ‘paths.h’, for ‘fstab’; and the macro ‘_PATH_MOUNTED’, also defined in
  5151. ‘mntent.h’ and ‘paths.h’, for ‘mtab’. There are also two alternate
  5152. macro names ‘FSTAB’, ‘MNTTAB’, and ‘MOUNTED’ defined but these names are
  5153. deprecated and kept only for backward compatibility. The names
  5154. ‘_PATH_MNTTAB’ and ‘_PATH_MOUNTED’ should always be used.
  5155. * Menu:
  5156. * fstab:: The ‘fstab’ file
  5157. * mtab:: The ‘mtab’ file
  5158. * Other Mount Information:: Other (non-libc) sources of mount information
  5159. 
  5160. File: libc.info, Node: fstab, Next: mtab, Up: Mount Information
  5161. 31.3.1.1 The ‘fstab’ file
  5162. .........................
  5163. The internal representation for entries of the file is ‘struct fstab’,
  5164. defined in ‘fstab.h’.
  5165. -- Data Type: struct fstab
  5166. This structure is used with the ‘getfsent’, ‘getfsspec’, and
  5167. ‘getfsfile’ functions.
  5168. ‘char *fs_spec’
  5169. This element describes the device from which the filesystem is
  5170. mounted. Normally this is the name of a special device, such
  5171. as a hard disk partition, but it could also be a more or less
  5172. generic string. For "NFS" it would be a hostname and
  5173. directory name combination.
  5174. Even though the element is not declared ‘const’ it shouldn’t
  5175. be modified. The missing ‘const’ has historic reasons, since
  5176. this function predates ISO C. The same is true for the other
  5177. string elements of this structure.
  5178. ‘char *fs_file’
  5179. This describes the mount point on the local system. I.e.,
  5180. accessing any file in this filesystem has implicitly or
  5181. explicitly this string as a prefix.
  5182. ‘char *fs_vfstype’
  5183. This is the type of the filesystem. Depending on what the
  5184. underlying kernel understands it can be any string.
  5185. ‘char *fs_mntops’
  5186. This is a string containing options passed to the kernel with
  5187. the ‘mount’ call. Again, this can be almost anything. There
  5188. can be more than one option, separated from the others by a
  5189. comma. Each option consists of a name and an optional value
  5190. part, introduced by an ‘=’ character.
  5191. If the value of this element must be processed it should
  5192. ideally be done using the ‘getsubopt’ function; see *note
  5193. Suboptions::.
  5194. ‘const char *fs_type’
  5195. This name is poorly chosen. This element points to a string
  5196. (possibly in the ‘fs_mntops’ string) which describes the modes
  5197. with which the filesystem is mounted. ‘fstab’ defines five
  5198. macros to describe the possible values:
  5199. ‘FSTAB_RW’
  5200. The filesystem gets mounted with read and write enabled.
  5201. ‘FSTAB_RQ’
  5202. The filesystem gets mounted with read and write enabled.
  5203. Write access is restricted by quotas.
  5204. ‘FSTAB_RO’
  5205. The filesystem gets mounted read-only.
  5206. ‘FSTAB_SW’
  5207. This is not a real filesystem, it is a swap device.
  5208. ‘FSTAB_XX’
  5209. This entry from the ‘fstab’ file is totally ignored.
  5210. Testing for equality with these values must happen using
  5211. ‘strcmp’ since these are all strings. Comparing the pointer
  5212. will probably always fail.
  5213. ‘int fs_freq’
  5214. This element describes the dump frequency in days.
  5215. ‘int fs_passno’
  5216. This element describes the pass number on parallel dumps. It
  5217. is closely related to the ‘dump’ utility used on Unix systems.
  5218. To read the entire content of the of the ‘fstab’ file the GNU C
  5219. Library contains a set of three functions which are designed in the
  5220. usual way.
  5221. -- Function: int setfsent (void)
  5222. Preliminary: | MT-Unsafe race:fsent | AS-Unsafe heap corrupt lock |
  5223. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  5224. This function makes sure that the internal read pointer for the
  5225. ‘fstab’ file is at the beginning of the file. This is done by
  5226. either opening the file or resetting the read pointer.
  5227. Since the file handle is internal to the libc this function is not
  5228. thread-safe.
  5229. This function returns a non-zero value if the operation was
  5230. successful and the ‘getfs*’ functions can be used to read the
  5231. entries of the file.
  5232. -- Function: void endfsent (void)
  5233. Preliminary: | MT-Unsafe race:fsent | AS-Unsafe heap corrupt lock |
  5234. AC-Unsafe corrupt lock mem fd | *Note POSIX Safety Concepts::.
  5235. This function makes sure that all resources acquired by a prior
  5236. call to ‘setfsent’ (explicitly or implicitly by calling ‘getfsent’)
  5237. are freed.
  5238. -- Function: struct fstab * getfsent (void)
  5239. Preliminary: | MT-Unsafe race:fsent locale | AS-Unsafe corrupt heap
  5240. lock | AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5241. This function returns the next entry of the ‘fstab’ file. If this
  5242. is the first call to any of the functions handling ‘fstab’ since
  5243. program start or the last call of ‘endfsent’, the file will be
  5244. opened.
  5245. The function returns a pointer to a variable of type ‘struct
  5246. fstab’. This variable is shared by all threads and therefore this
  5247. function is not thread-safe. If an error occurred ‘getfsent’
  5248. returns a ‘NULL’ pointer.
  5249. -- Function: struct fstab * getfsspec (const char *NAME)
  5250. Preliminary: | MT-Unsafe race:fsent locale | AS-Unsafe corrupt heap
  5251. lock | AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5252. This function returns the next entry of the ‘fstab’ file which has
  5253. a string equal to NAME pointed to by the ‘fs_spec’ element. Since
  5254. there is normally exactly one entry for each special device it
  5255. makes no sense to call this function more than once for the same
  5256. argument. If this is the first call to any of the functions
  5257. handling ‘fstab’ since program start or the last call of
  5258. ‘endfsent’, the file will be opened.
  5259. The function returns a pointer to a variable of type ‘struct
  5260. fstab’. This variable is shared by all threads and therefore this
  5261. function is not thread-safe. If an error occurred ‘getfsent’
  5262. returns a ‘NULL’ pointer.
  5263. -- Function: struct fstab * getfsfile (const char *NAME)
  5264. Preliminary: | MT-Unsafe race:fsent locale | AS-Unsafe corrupt heap
  5265. lock | AC-Unsafe corrupt lock mem | *Note POSIX Safety Concepts::.
  5266. This function returns the next entry of the ‘fstab’ file which has
  5267. a string equal to NAME pointed to by the ‘fs_file’ element. Since
  5268. there is normally exactly one entry for each mount point it makes
  5269. no sense to call this function more than once for the same
  5270. argument. If this is the first call to any of the functions
  5271. handling ‘fstab’ since program start or the last call of
  5272. ‘endfsent’, the file will be opened.
  5273. The function returns a pointer to a variable of type ‘struct
  5274. fstab’. This variable is shared by all threads and therefore this
  5275. function is not thread-safe. If an error occurred ‘getfsent’
  5276. returns a ‘NULL’ pointer.
  5277. 
  5278. File: libc.info, Node: mtab, Next: Other Mount Information, Prev: fstab, Up: Mount Information
  5279. 31.3.1.2 The ‘mtab’ file
  5280. ........................
  5281. The following functions and data structure access the ‘mtab’ file.
  5282. -- Data Type: struct mntent
  5283. This structure is used with the ‘getmntent’, ‘getmntent_r’,
  5284. ‘addmntent’, and ‘hasmntopt’ functions.
  5285. ‘char *mnt_fsname’
  5286. This element contains a pointer to a string describing the
  5287. name of the special device from which the filesystem is
  5288. mounted. It corresponds to the ‘fs_spec’ element in ‘struct
  5289. fstab’.
  5290. ‘char *mnt_dir’
  5291. This element points to a string describing the mount point of
  5292. the filesystem. It corresponds to the ‘fs_file’ element in
  5293. ‘struct fstab’.
  5294. ‘char *mnt_type’
  5295. ‘mnt_type’ describes the filesystem type and is therefore
  5296. equivalent to ‘fs_vfstype’ in ‘struct fstab’. ‘mntent.h’
  5297. defines a few symbolic names for some of the values this
  5298. string can have. But since the kernel can support arbitrary
  5299. filesystems it does not make much sense to give them symbolic
  5300. names. If one knows the symbol name one also knows the
  5301. filesystem name. Nevertheless here follows the list of the
  5302. symbols provided in ‘mntent.h’.
  5303. ‘MNTTYPE_IGNORE’
  5304. This symbol expands to ‘"ignore"’. The value is
  5305. sometimes used in ‘fstab’ files to make sure entries are
  5306. not used without removing them.
  5307. ‘MNTTYPE_NFS’
  5308. Expands to ‘"nfs"’. Using this macro sometimes could
  5309. make sense since it names the default NFS implementation,
  5310. in case both version 2 and 3 are supported.
  5311. ‘MNTTYPE_SWAP’
  5312. This symbol expands to ‘"swap"’. It names the special
  5313. ‘fstab’ entry which names one of the possibly multiple
  5314. swap partitions.
  5315. ‘char *mnt_opts’
  5316. The element contains a string describing the options used
  5317. while mounting the filesystem. As for the equivalent element
  5318. ‘fs_mntops’ of ‘struct fstab’ it is best to use the function
  5319. ‘getsubopt’ (*note Suboptions::) to access the parts of this
  5320. string.
  5321. The ‘mntent.h’ file defines a number of macros with string
  5322. values which correspond to some of the options understood by
  5323. the kernel. There might be many more options which are
  5324. possible so it doesn’t make much sense to rely on these macros
  5325. but to be consistent here is the list:
  5326. ‘MNTOPT_DEFAULTS’
  5327. Expands to ‘"defaults"’. This option should be used
  5328. alone since it indicates all values for the customizable
  5329. values are chosen to be the default.
  5330. ‘MNTOPT_RO’
  5331. Expands to ‘"ro"’. See the ‘FSTAB_RO’ value, it means
  5332. the filesystem is mounted read-only.
  5333. ‘MNTOPT_RW’
  5334. Expands to ‘"rw"’. See the ‘FSTAB_RW’ value, it means
  5335. the filesystem is mounted with read and write
  5336. permissions.
  5337. ‘MNTOPT_SUID’
  5338. Expands to ‘"suid"’. This means that the SUID bit (*note
  5339. How Change Persona::) is respected when a program from
  5340. the filesystem is started.
  5341. ‘MNTOPT_NOSUID’
  5342. Expands to ‘"nosuid"’. This is the opposite of
  5343. ‘MNTOPT_SUID’, the SUID bit for all files from the
  5344. filesystem is ignored.
  5345. ‘MNTOPT_NOAUTO’
  5346. Expands to ‘"noauto"’. At startup time the ‘mount’
  5347. program will ignore this entry if it is started with the
  5348. ‘-a’ option to mount all filesystems mentioned in the
  5349. ‘fstab’ file.
  5350. As for the ‘FSTAB_*’ entries introduced above it is important
  5351. to use ‘strcmp’ to check for equality.
  5352. ‘mnt_freq’
  5353. This elements corresponds to ‘fs_freq’ and also specifies the
  5354. frequency in days in which dumps are made.
  5355. ‘mnt_passno’
  5356. This element is equivalent to ‘fs_passno’ with the same
  5357. meaning which is uninteresting for all programs beside ‘dump’.
  5358. For accessing the ‘mtab’ file there is again a set of three functions
  5359. to access all entries in a row. Unlike the functions to handle ‘fstab’
  5360. these functions do not access a fixed file and there is even a thread
  5361. safe variant of the get function. Besides this the GNU C Library
  5362. contains functions to alter the file and test for specific options.
  5363. -- Function: FILE * setmntent (const char *FILE, const char *MODE)
  5364. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe mem fd
  5365. lock | *Note POSIX Safety Concepts::.
  5366. The ‘setmntent’ function prepares the file named FILE which must be
  5367. in the format of a ‘fstab’ and ‘mtab’ file for the upcoming
  5368. processing through the other functions of the family. The MODE
  5369. parameter can be chosen in the way the OPENTYPE parameter for
  5370. ‘fopen’ (*note Opening Streams::) can be chosen. If the file is
  5371. opened for writing the file is also allowed to be empty.
  5372. If the file was successfully opened ‘setmntent’ returns a file
  5373. handle for future use. Otherwise the return value is ‘NULL’ and
  5374. ‘errno’ is set accordingly.
  5375. -- Function: int endmntent (FILE *STREAM)
  5376. Preliminary: | MT-Safe | AS-Unsafe heap lock | AC-Unsafe lock mem
  5377. fd | *Note POSIX Safety Concepts::.
  5378. This function takes for the STREAM parameter a file handle which
  5379. previously was returned from the ‘setmntent’ call. ‘endmntent’
  5380. closes the stream and frees all resources.
  5381. The return value is 1 unless an error occurred in which case it is
  5382. 0.
  5383. -- Function: struct mntent * getmntent (FILE *STREAM)
  5384. Preliminary: | MT-Unsafe race:mntentbuf locale | AS-Unsafe corrupt
  5385. heap init | AC-Unsafe init corrupt lock mem | *Note POSIX Safety
  5386. Concepts::.
  5387. The ‘getmntent’ function takes as the parameter a file handle
  5388. previously returned by a successful call to ‘setmntent’. It
  5389. returns a pointer to a static variable of type ‘struct mntent’
  5390. which is filled with the information from the next entry from the
  5391. file currently read.
  5392. The file format used prescribes the use of spaces or tab characters
  5393. to separate the fields. This makes it harder to use names
  5394. containing one of these characters (e.g., mount points using
  5395. spaces). Therefore these characters are encoded in the files and
  5396. the ‘getmntent’ function takes care of the decoding while reading
  5397. the entries back in. ‘'\040'’ is used to encode a space character,
  5398. ‘'\011'’ to encode a tab character, ‘'\012'’ to encode a newline
  5399. character, and ‘'\\'’ to encode a backslash.
  5400. If there was an error or the end of the file is reached the return
  5401. value is ‘NULL’.
  5402. This function is not thread-safe since all calls to this function
  5403. return a pointer to the same static variable. ‘getmntent_r’ should
  5404. be used in situations where multiple threads access the file.
  5405. -- Function: struct mntent * getmntent_r (FILE *STREAM, struct mntent
  5406. *RESULT, char *BUFFER, int BUFSIZE)
  5407. Preliminary: | MT-Safe locale | AS-Unsafe corrupt heap | AC-Unsafe
  5408. corrupt lock mem | *Note POSIX Safety Concepts::.
  5409. The ‘getmntent_r’ function is the reentrant variant of ‘getmntent’.
  5410. It also returns the next entry from the file and returns a pointer.
  5411. The actual variable the values are stored in is not static, though.
  5412. Instead the function stores the values in the variable pointed to
  5413. by the RESULT parameter. Additional information (e.g., the strings
  5414. pointed to by the elements of the result) are kept in the buffer of
  5415. size BUFSIZE pointed to by BUFFER.
  5416. Escaped characters (space, tab, backslash) are converted back in
  5417. the same way as it happens for ‘getmentent’.
  5418. The function returns a ‘NULL’ pointer in error cases. Errors could
  5419. be:
  5420. • error while reading the file,
  5421. • end of file reached,
  5422. • BUFSIZE is too small for reading a complete new entry.
  5423. -- Function: int addmntent (FILE *STREAM, const struct mntent *MNT)
  5424. Preliminary: | MT-Safe race:stream locale | AS-Unsafe corrupt |
  5425. AC-Unsafe corrupt | *Note POSIX Safety Concepts::.
  5426. The ‘addmntent’ function allows adding a new entry to the file
  5427. previously opened with ‘setmntent’. The new entries are always
  5428. appended. I.e., even if the position of the file descriptor is not
  5429. at the end of the file this function does not overwrite an existing
  5430. entry following the current position.
  5431. The implication of this is that to remove an entry from a file one
  5432. has to create a new file while leaving out the entry to be removed
  5433. and after closing the file remove the old one and rename the new
  5434. file to the chosen name.
  5435. This function takes care of spaces and tab characters in the names
  5436. to be written to the file. It converts them and the backslash
  5437. character into the format described in the ‘getmntent’ description
  5438. above.
  5439. This function returns 0 in case the operation was successful.
  5440. Otherwise the return value is 1 and ‘errno’ is set appropriately.
  5441. -- Function: char * hasmntopt (const struct mntent *MNT, const char
  5442. *OPT)
  5443. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5444. Concepts::.
  5445. This function can be used to check whether the string pointed to by
  5446. the ‘mnt_opts’ element of the variable pointed to by MNT contains
  5447. the option OPT. If this is true a pointer to the beginning of the
  5448. option in the ‘mnt_opts’ element is returned. If no such option
  5449. exists the function returns ‘NULL’.
  5450. This function is useful to test whether a specific option is
  5451. present but when all options have to be processed one is better off
  5452. with using the ‘getsubopt’ function to iterate over all options in
  5453. the string.
  5454. 
  5455. File: libc.info, Node: Other Mount Information, Prev: mtab, Up: Mount Information
  5456. 31.3.1.3 Other (Non-libc) Sources of Mount Information
  5457. ......................................................
  5458. On a system with a Linux kernel and the ‘proc’ filesystem, you can get
  5459. information on currently mounted filesystems from the file ‘mounts’ in
  5460. the ‘proc’ filesystem. Its format is similar to that of the ‘mtab’
  5461. file, but represents what is truly mounted without relying on facilities
  5462. outside the kernel to keep ‘mtab’ up to date.
  5463. 
  5464. File: libc.info, Node: Mount-Unmount-Remount, Prev: Mount Information, Up: Filesystem Handling
  5465. 31.3.2 Mount, Unmount, Remount
  5466. ------------------------------
  5467. This section describes the functions for mounting, unmounting, and
  5468. remounting filesystems.
  5469. Only the superuser can mount, unmount, or remount a filesystem.
  5470. These functions do not access the ‘fstab’ and ‘mtab’ files. You
  5471. should maintain and use these separately. *Note Mount Information::.
  5472. The symbols in this section are declared in ‘sys/mount.h’.
  5473. -- Function: int mount (const char *SPECIAL_FILE, const char *DIR,
  5474. const char *FSTYPE, unsigned long int OPTIONS, const void
  5475. *DATA)
  5476. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5477. Concepts::.
  5478. ‘mount’ mounts or remounts a filesystem. The two operations are
  5479. quite different and are merged rather unnaturally into this one
  5480. function. The ‘MS_REMOUNT’ option, explained below, determines
  5481. whether ‘mount’ mounts or remounts.
  5482. For a mount, the filesystem on the block device represented by the
  5483. device special file named SPECIAL_FILE gets mounted over the mount
  5484. point DIR. This means that the directory DIR (along with any files
  5485. in it) is no longer visible; in its place (and still with the name
  5486. DIR) is the root directory of the filesystem on the device.
  5487. As an exception, if the filesystem type (see below) is one which is
  5488. not based on a device (e.g. “proc”), ‘mount’ instantiates a
  5489. filesystem and mounts it over DIR and ignores SPECIAL_FILE.
  5490. For a remount, DIR specifies the mount point where the filesystem
  5491. to be remounted is (and remains) mounted and SPECIAL_FILE is
  5492. ignored. Remounting a filesystem means changing the options that
  5493. control operations on the filesystem while it is mounted. It does
  5494. not mean unmounting and mounting again.
  5495. For a mount, you must identify the type of the filesystem with
  5496. FSTYPE. This type tells the kernel how to access the filesystem
  5497. and can be thought of as the name of a filesystem driver. The
  5498. acceptable values are system dependent. On a system with a Linux
  5499. kernel and the ‘proc’ filesystem, the list of possible values is in
  5500. the file ‘filesystems’ in the ‘proc’ filesystem (e.g. type ‘cat
  5501. /proc/filesystems’ to see the list). With a Linux kernel, the
  5502. types of filesystems that ‘mount’ can mount, and their type names,
  5503. depends on what filesystem drivers are configured into the kernel
  5504. or loaded as loadable kernel modules. An example of a common value
  5505. for FSTYPE is ‘ext2’.
  5506. For a remount, ‘mount’ ignores FSTYPE.
  5507. OPTIONS specifies a variety of options that apply until the
  5508. filesystem is unmounted or remounted. The precise meaning of an
  5509. option depends on the filesystem and with some filesystems, an
  5510. option may have no effect at all. Furthermore, for some
  5511. filesystems, some of these options (but never ‘MS_RDONLY’) can be
  5512. overridden for individual file accesses via ‘ioctl’.
  5513. OPTIONS is a bit string with bit fields defined using the following
  5514. mask and masked value macros:
  5515. ‘MS_MGC_MASK’
  5516. This multibit field contains a magic number. If it does not
  5517. have the value ‘MS_MGC_VAL’, ‘mount’ assumes all the following
  5518. bits are zero and the DATA argument is a null string,
  5519. regardless of their actual values.
  5520. ‘MS_REMOUNT’
  5521. This bit on means to remount the filesystem. Off means to
  5522. mount it.
  5523. ‘MS_RDONLY’
  5524. This bit on specifies that no writing to the filesystem shall
  5525. be allowed while it is mounted. This cannot be overridden by
  5526. ‘ioctl’. This option is available on nearly all filesystems.
  5527. ‘MS_NOSUID’
  5528. This bit on specifies that Setuid and Setgid permissions on
  5529. files in the filesystem shall be ignored while it is mounted.
  5530. ‘MS_NOEXEC’
  5531. This bit on specifies that no files in the filesystem shall be
  5532. executed while the filesystem is mounted.
  5533. ‘MS_NODEV’
  5534. This bit on specifies that no device special files in the
  5535. filesystem shall be accessible while the filesystem is
  5536. mounted.
  5537. ‘MS_SYNCHRONOUS’
  5538. This bit on specifies that all writes to the filesystem while
  5539. it is mounted shall be synchronous; i.e., data shall be synced
  5540. before each write completes rather than held in the buffer
  5541. cache.
  5542. ‘MS_MANDLOCK’
  5543. This bit on specifies that mandatory locks on files shall be
  5544. permitted while the filesystem is mounted.
  5545. ‘MS_NOATIME’
  5546. This bit on specifies that access times of files shall not be
  5547. updated when the files are accessed while the filesystem is
  5548. mounted.
  5549. ‘MS_NODIRATIME’
  5550. This bit on specifies that access times of directories shall
  5551. not be updated when the directories are accessed while the
  5552. filesystem in mounted.
  5553. Any bits not covered by the above masks should be set off;
  5554. otherwise, results are undefined.
  5555. The meaning of DATA depends on the filesystem type and is
  5556. controlled entirely by the filesystem driver in the kernel.
  5557. Example:
  5558. #include <sys/mount.h>
  5559. mount("/dev/hdb", "/cdrom", MS_MGC_VAL | MS_RDONLY | MS_NOSUID, "");
  5560. mount("/dev/hda2", "/mnt", MS_MGC_VAL | MS_REMOUNT, "");
  5561. Appropriate arguments for ‘mount’ are conventionally recorded in
  5562. the ‘fstab’ table. *Note Mount Information::.
  5563. The return value is zero if the mount or remount is successful.
  5564. Otherwise, it is ‘-1’ and ‘errno’ is set appropriately. The values
  5565. of ‘errno’ are filesystem dependent, but here is a general list:
  5566. ‘EPERM’
  5567. The process is not superuser.
  5568. ‘ENODEV’
  5569. The file system type FSTYPE is not known to the kernel.
  5570. ‘ENOTBLK’
  5571. The file DEV is not a block device special file.
  5572. ‘EBUSY’
  5573. • The device is already mounted.
  5574. • The mount point is busy. (E.g. it is some process’
  5575. working directory or has a filesystem mounted on it
  5576. already).
  5577. • The request is to remount read-only, but there are files
  5578. open for writing.
  5579. ‘EINVAL’
  5580. • A remount was attempted, but there is no filesystem
  5581. mounted over the specified mount point.
  5582. • The supposed filesystem has an invalid superblock.
  5583. ‘EACCES’
  5584. • The filesystem is inherently read-only (possibly due to a
  5585. switch on the device) and the process attempted to mount
  5586. it read/write (by setting the ‘MS_RDONLY’ bit off).
  5587. • SPECIAL_FILE or DIR is not accessible due to file
  5588. permissions.
  5589. • SPECIAL_FILE is not accessible because it is in a
  5590. filesystem that is mounted with the ‘MS_NODEV’ option.
  5591. ‘EM_FILE’
  5592. The table of dummy devices is full. ‘mount’ needs to create a
  5593. dummy device (aka “unnamed” device) if the filesystem being
  5594. mounted is not one that uses a device.
  5595. -- Function: int umount2 (const char *FILE, int FLAGS)
  5596. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5597. Concepts::.
  5598. ‘umount2’ unmounts a filesystem.
  5599. You can identify the filesystem to unmount either by the device
  5600. special file that contains the filesystem or by the mount point.
  5601. The effect is the same. Specify either as the string FILE.
  5602. FLAGS contains the one-bit field identified by the following mask
  5603. macro:
  5604. ‘MNT_FORCE’
  5605. This bit on means to force the unmounting even if the
  5606. filesystem is busy, by making it unbusy first. If the bit is
  5607. off and the filesystem is busy, ‘umount2’ fails with ‘errno’ =
  5608. ‘EBUSY’. Depending on the filesystem, this may override all,
  5609. some, or no busy conditions.
  5610. All other bits in FLAGS should be set to zero; otherwise, the
  5611. result is undefined.
  5612. Example:
  5613. #include <sys/mount.h>
  5614. umount2("/mnt", MNT_FORCE);
  5615. umount2("/dev/hdd1", 0);
  5616. After the filesystem is unmounted, the directory that was the mount
  5617. point is visible, as are any files in it.
  5618. As part of unmounting, ‘umount2’ syncs the filesystem.
  5619. If the unmounting is successful, the return value is zero.
  5620. Otherwise, it is ‘-1’ and ‘errno’ is set accordingly:
  5621. ‘EPERM’
  5622. The process is not superuser.
  5623. ‘EBUSY’
  5624. The filesystem cannot be unmounted because it is busy. E.g.
  5625. it contains a directory that is some process’s working
  5626. directory or a file that some process has open. With some
  5627. filesystems in some cases, you can avoid this failure with the
  5628. ‘MNT_FORCE’ option.
  5629. ‘EINVAL’
  5630. FILE validly refers to a file, but that file is neither a
  5631. mount point nor a device special file of a currently mounted
  5632. filesystem.
  5633. This function is not available on all systems.
  5634. -- Function: int umount (const char *FILE)
  5635. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5636. Concepts::.
  5637. ‘umount’ does the same thing as ‘umount2’ with FLAGS set to zeroes.
  5638. It is more widely available than ‘umount2’ but since it lacks the
  5639. possibility to forcefully unmount a filesystem is deprecated when
  5640. ‘umount2’ is also available.
  5641. 
  5642. File: libc.info, Node: System Parameters, Prev: Filesystem Handling, Up: System Management
  5643. 31.4 System Parameters
  5644. ======================
  5645. This section describes the ‘sysctl’ function, which gets and sets a
  5646. variety of system parameters.
  5647. The symbols used in this section are declared in the file
  5648. ‘sys/sysctl.h’.
  5649. -- Function: int sysctl (int *NAMES, int NLEN, void *OLDVAL, size_t
  5650. *OLDLENP, void *NEWVAL, size_t NEWLEN)
  5651. Preliminary: | MT-Safe | AS-Safe | AC-Safe | *Note POSIX Safety
  5652. Concepts::.
  5653. ‘sysctl’ gets or sets a specified system parameter. There are so
  5654. many of these parameters that it is not practical to list them all
  5655. here, but here are some examples:
  5656. • network domain name
  5657. • paging parameters
  5658. • network Address Resolution Protocol timeout time
  5659. • maximum number of files that may be open
  5660. • root filesystem device
  5661. • when kernel was built
  5662. The set of available parameters depends on the kernel configuration
  5663. and can change while the system is running, particularly when you
  5664. load and unload loadable kernel modules.
  5665. The system parameters with which ‘sysctl’ is concerned are arranged
  5666. in a hierarchical structure like a hierarchical filesystem. To
  5667. identify a particular parameter, you specify a path through the
  5668. structure in a way analogous to specifying the pathname of a file.
  5669. Each component of the path is specified by an integer and each of
  5670. these integers has a macro defined for it by ‘sys/sysctl.h’. NAMES
  5671. is the path, in the form of an array of integers. Each component
  5672. of the path is one element of the array, in order. NLEN is the
  5673. number of components in the path.
  5674. For example, the first component of the path for all the paging
  5675. parameters is the value ‘CTL_VM’. For the free page thresholds,
  5676. the second component of the path is ‘VM_FREEPG’. So to get the
  5677. free page threshold values, make NAMES an array containing the two
  5678. elements ‘CTL_VM’ and ‘VM_FREEPG’ and make NLEN = 2.
  5679. The format of the value of a parameter depends on the parameter.
  5680. Sometimes it is an integer; sometimes it is an ASCII string;
  5681. sometimes it is an elaborate structure. In the case of the free
  5682. page thresholds used in the example above, the parameter value is a
  5683. structure containing several integers.
  5684. In any case, you identify a place to return the parameter’s value
  5685. with OLDVAL and specify the amount of storage available at that
  5686. location as *OLDLENP. *OLDLENP does double duty because it is also
  5687. the output location that contains the actual length of the returned
  5688. value.
  5689. If you don’t want the parameter value returned, specify a null
  5690. pointer for OLDVAL.
  5691. To set the parameter, specify the address and length of the new
  5692. value as NEWVAL and NEWLEN. If you don’t want to set the
  5693. parameter, specify a null pointer as NEWVAL.
  5694. If you get and set a parameter in the same ‘sysctl’ call, the value
  5695. returned is the value of the parameter before it was set.
  5696. Each system parameter has a set of permissions similar to the
  5697. permissions for a file (including the permissions on directories in
  5698. its path) that determine whether you may get or set it. For the
  5699. purposes of these permissions, every parameter is considered to be
  5700. owned by the superuser and Group 0 so processes with that effective
  5701. uid or gid may have more access to system parameters. Unlike with
  5702. files, the superuser does not invariably have full permission to
  5703. all system parameters, because some of them are designed not to be
  5704. changed ever.
  5705. ‘sysctl’ returns a zero return value if it succeeds. Otherwise, it
  5706. returns ‘-1’ and sets ‘errno’ appropriately. Besides the failures
  5707. that apply to all system calls, the following are the ‘errno’ codes
  5708. for all possible failures:
  5709. ‘EPERM’
  5710. The process is not permitted to access one of the components
  5711. of the path of the system parameter or is not permitted to
  5712. access the system parameter itself in the way (read or write)
  5713. that it requested.
  5714. ‘ENOTDIR’
  5715. There is no system parameter corresponding to NAME.
  5716. ‘EFAULT’
  5717. OLDVAL is not null, which means the process wanted to read the
  5718. parameter, but *OLDLENP is zero, so there is no place to
  5719. return it.
  5720. ‘EINVAL’
  5721. • The process attempted to set a system parameter to a
  5722. value that is not valid for that parameter.
  5723. • The space provided for the return of the system parameter
  5724. is not the right size for that parameter.
  5725. ‘ENOMEM’
  5726. This value may be returned instead of the more correct
  5727. ‘EINVAL’ in some cases where the space provided for the return
  5728. of the system parameter is too small.
  5729. If you have a Linux kernel with the ‘proc’ filesystem, you can get
  5730. and set most of the same parameters by reading and writing to files in
  5731. the ‘sys’ directory of the ‘proc’ filesystem. In the ‘sys’ directory,
  5732. the directory structure represents the hierarchical structure of the
  5733. parameters. E.g. you can display the free page thresholds with
  5734. cat /proc/sys/vm/freepages
  5735. Some more traditional and more widely available, though less general,
  5736. GNU C Library functions for getting and setting some of the same system
  5737. parameters are:
  5738. • ‘getdomainname’, ‘setdomainname’
  5739. • ‘gethostname’, ‘sethostname’ (*Note Host Identification::.)
  5740. • ‘uname’ (*Note Platform Type::.)
  5741. 
  5742. File: libc.info, Node: System Configuration, Next: Cryptographic Functions, Prev: System Management, Up: Top
  5743. 32 System Configuration Parameters
  5744. **********************************
  5745. The functions and macros listed in this chapter give information about
  5746. configuration parameters of the operating system—for example, capacity
  5747. limits, presence of optional POSIX features, and the default path for
  5748. executable files (*note String Parameters::).
  5749. * Menu:
  5750. * General Limits:: Constants and functions that describe
  5751. various process-related limits that have
  5752. one uniform value for any given machine.
  5753. * System Options:: Optional POSIX features.
  5754. * Version Supported:: Version numbers of POSIX.1 and POSIX.2.
  5755. * Sysconf:: Getting specific configuration values
  5756. of general limits and system options.
  5757. * Minimums:: Minimum values for general limits.
  5758. * Limits for Files:: Size limitations that pertain to individual files.
  5759. These can vary between file systems
  5760. or even from file to file.
  5761. * Options for Files:: Optional features that some files may support.
  5762. * File Minimums:: Minimum values for file limits.
  5763. * Pathconf:: Getting the limit values for a particular file.
  5764. * Utility Limits:: Capacity limits of some POSIX.2 utility programs.
  5765. * Utility Minimums:: Minimum allowable values of those limits.
  5766. * String Parameters:: Getting the default search path.
  5767. 
  5768. File: libc.info, Node: General Limits, Next: System Options, Up: System Configuration
  5769. 32.1 General Capacity Limits
  5770. ============================
  5771. The POSIX.1 and POSIX.2 standards specify a number of parameters that
  5772. describe capacity limitations of the system. These limits can be fixed
  5773. constants for a given operating system, or they can vary from machine to
  5774. machine. For example, some limit values may be configurable by the
  5775. system administrator, either at run time or by rebuilding the kernel,
  5776. and this should not require recompiling application programs.
  5777. Each of the following limit parameters has a macro that is defined in
  5778. ‘limits.h’ only if the system has a fixed, uniform limit for the
  5779. parameter in question. If the system allows different file systems or
  5780. files to have different limits, then the macro is undefined; use
  5781. ‘sysconf’ to find out the limit that applies at a particular time on a
  5782. particular machine. *Note Sysconf::.
  5783. Each of these parameters also has another macro, with a name starting
  5784. with ‘_POSIX’, which gives the lowest value that the limit is allowed to
  5785. have on _any_ POSIX system. *Note Minimums::.
  5786. -- Macro: int ARG_MAX
  5787. If defined, the unvarying maximum combined length of the ARGV and
  5788. ENVIRON arguments that can be passed to the ‘exec’ functions.
  5789. -- Macro: int CHILD_MAX
  5790. If defined, the unvarying maximum number of processes that can
  5791. exist with the same real user ID at any one time. In BSD and GNU,
  5792. this is controlled by the ‘RLIMIT_NPROC’ resource limit; *note
  5793. Limits on Resources::.
  5794. -- Macro: int OPEN_MAX
  5795. If defined, the unvarying maximum number of files that a single
  5796. process can have open simultaneously. In BSD and GNU, this is
  5797. controlled by the ‘RLIMIT_NOFILE’ resource limit; *note Limits on
  5798. Resources::.
  5799. -- Macro: int STREAM_MAX
  5800. If defined, the unvarying maximum number of streams that a single
  5801. process can have open simultaneously. *Note Opening Streams::.
  5802. -- Macro: int TZNAME_MAX
  5803. If defined, the unvarying maximum length of a time zone name.
  5804. *Note Time Zone Functions::.
  5805. These limit macros are always defined in ‘limits.h’.
  5806. -- Macro: int NGROUPS_MAX
  5807. The maximum number of supplementary group IDs that one process can
  5808. have.
  5809. The value of this macro is actually a lower bound for the maximum.
  5810. That is, you can count on being able to have that many
  5811. supplementary group IDs, but a particular machine might let you
  5812. have even more. You can use ‘sysconf’ to see whether a particular
  5813. machine will let you have more (*note Sysconf::).
  5814. -- Macro: ssize_t SSIZE_MAX
  5815. The largest value that can fit in an object of type ‘ssize_t’.
  5816. Effectively, this is the limit on the number of bytes that can be
  5817. read or written in a single operation.
  5818. This macro is defined in all POSIX systems because this limit is
  5819. never configurable.
  5820. -- Macro: int RE_DUP_MAX
  5821. The largest number of repetitions you are guaranteed is allowed in
  5822. the construct ‘\{MIN,MAX\}’ in a regular expression.
  5823. The value of this macro is actually a lower bound for the maximum.
  5824. That is, you can count on being able to have that many repetitions,
  5825. but a particular machine might let you have even more. You can use
  5826. ‘sysconf’ to see whether a particular machine will let you have
  5827. more (*note Sysconf::). And even the value that ‘sysconf’ tells
  5828. you is just a lower bound—larger values might work.
  5829. This macro is defined in all POSIX.2 systems, because POSIX.2 says
  5830. it should always be defined even if there is no specific imposed
  5831. limit.
  5832. 
  5833. File: libc.info, Node: System Options, Next: Version Supported, Prev: General Limits, Up: System Configuration
  5834. 32.2 Overall System Options
  5835. ===========================
  5836. POSIX defines certain system-specific options that not all POSIX systems
  5837. support. Since these options are provided in the kernel, not in the
  5838. library, simply using the GNU C Library does not guarantee any of these
  5839. features are supported; it depends on the system you are using.
  5840. You can test for the availability of a given option using the macros
  5841. in this section, together with the function ‘sysconf’. The macros are
  5842. defined only if you include ‘unistd.h’.
  5843. For the following macros, if the macro is defined in ‘unistd.h’, then
  5844. the option is supported. Otherwise, the option may or may not be
  5845. supported; use ‘sysconf’ to find out. *Note Sysconf::.
  5846. -- Macro: int _POSIX_JOB_CONTROL
  5847. If this symbol is defined, it indicates that the system supports
  5848. job control. Otherwise, the implementation behaves as if all
  5849. processes within a session belong to a single process group. *Note
  5850. Job Control::.
  5851. -- Macro: int _POSIX_SAVED_IDS
  5852. If this symbol is defined, it indicates that the system remembers
  5853. the effective user and group IDs of a process before it executes an
  5854. executable file with the set-user-ID or set-group-ID bits set, and
  5855. that explicitly changing the effective user or group IDs back to
  5856. these values is permitted. If this option is not defined, then if
  5857. a nonprivileged process changes its effective user or group ID to
  5858. the real user or group ID of the process, it can’t change it back
  5859. again. *Note Enable/Disable Setuid::.
  5860. For the following macros, if the macro is defined in ‘unistd.h’, then
  5861. its value indicates whether the option is supported. A value of ‘-1’
  5862. means no, and any other value means yes. If the macro is not defined,
  5863. then the option may or may not be supported; use ‘sysconf’ to find out.
  5864. *Note Sysconf::.
  5865. -- Macro: int _POSIX2_C_DEV
  5866. If this symbol is defined, it indicates that the system has the
  5867. POSIX.2 C compiler command, ‘c89’. The GNU C Library always
  5868. defines this as ‘1’, on the assumption that you would not have
  5869. installed it if you didn’t have a C compiler.
  5870. -- Macro: int _POSIX2_FORT_DEV
  5871. If this symbol is defined, it indicates that the system has the
  5872. POSIX.2 Fortran compiler command, ‘fort77’. The GNU C Library
  5873. never defines this, because we don’t know what the system has.
  5874. -- Macro: int _POSIX2_FORT_RUN
  5875. If this symbol is defined, it indicates that the system has the
  5876. POSIX.2 ‘asa’ command to interpret Fortran carriage control. The
  5877. GNU C Library never defines this, because we don’t know what the
  5878. system has.
  5879. -- Macro: int _POSIX2_LOCALEDEF
  5880. If this symbol is defined, it indicates that the system has the
  5881. POSIX.2 ‘localedef’ command. The GNU C Library never defines this,
  5882. because we don’t know what the system has.
  5883. -- Macro: int _POSIX2_SW_DEV
  5884. If this symbol is defined, it indicates that the system has the
  5885. POSIX.2 commands ‘ar’, ‘make’, and ‘strip’. The GNU C Library
  5886. always defines this as ‘1’, on the assumption that you had to have
  5887. ‘ar’ and ‘make’ to install the library, and it’s unlikely that
  5888. ‘strip’ would be absent when those are present.
  5889. 
  5890. File: libc.info, Node: Version Supported, Next: Sysconf, Prev: System Options, Up: System Configuration
  5891. 32.3 Which Version of POSIX is Supported
  5892. ========================================
  5893. -- Macro: long int _POSIX_VERSION
  5894. This constant represents the version of the POSIX.1 standard to
  5895. which the implementation conforms. For an implementation
  5896. conforming to the 1995 POSIX.1 standard, the value is the integer
  5897. ‘199506L’.
  5898. ‘_POSIX_VERSION’ is always defined (in ‘unistd.h’) in any POSIX
  5899. system.
  5900. *Usage Note:* Don’t try to test whether the system supports POSIX
  5901. by including ‘unistd.h’ and then checking whether ‘_POSIX_VERSION’
  5902. is defined. On a non-POSIX system, this will probably fail because
  5903. there is no ‘unistd.h’. We do not know of _any_ way you can
  5904. reliably test at compilation time whether your target system
  5905. supports POSIX or whether ‘unistd.h’ exists.
  5906. -- Macro: long int _POSIX2_C_VERSION
  5907. This constant represents the version of the POSIX.2 standard which
  5908. the library and system kernel support. We don’t know what value
  5909. this will be for the first version of the POSIX.2 standard, because
  5910. the value is based on the year and month in which the standard is
  5911. officially adopted.
  5912. The value of this symbol says nothing about the utilities installed
  5913. on the system.
  5914. *Usage Note:* You can use this macro to tell whether a POSIX.1
  5915. system library supports POSIX.2 as well. Any POSIX.1 system
  5916. contains ‘unistd.h’, so include that file and then test ‘defined
  5917. (_POSIX2_C_VERSION)’.
  5918. 
  5919. File: libc.info, Node: Sysconf, Next: Minimums, Prev: Version Supported, Up: System Configuration
  5920. 32.4 Using ‘sysconf’
  5921. ====================
  5922. When your system has configurable system limits, you can use the
  5923. ‘sysconf’ function to find out the value that applies to any particular
  5924. machine. The function and the associated PARAMETER constants are
  5925. declared in the header file ‘unistd.h’.
  5926. * Menu:
  5927. * Sysconf Definition:: Detailed specifications of ‘sysconf’.
  5928. * Constants for Sysconf:: The list of parameters ‘sysconf’ can read.
  5929. * Examples of Sysconf:: How to use ‘sysconf’ and the parameter
  5930. macros properly together.
  5931. 
  5932. File: libc.info, Node: Sysconf Definition, Next: Constants for Sysconf, Up: Sysconf
  5933. 32.4.1 Definition of ‘sysconf’
  5934. ------------------------------
  5935. -- Function: long int sysconf (int PARAMETER)
  5936. Preliminary: | MT-Safe env | AS-Unsafe lock heap | AC-Unsafe lock
  5937. mem fd | *Note POSIX Safety Concepts::.
  5938. This function is used to inquire about runtime system parameters.
  5939. The PARAMETER argument should be one of the ‘_SC_’ symbols listed
  5940. below.
  5941. The normal return value from ‘sysconf’ is the value you requested.
  5942. A value of ‘-1’ is returned both if the implementation does not
  5943. impose a limit, and in case of an error.
  5944. The following ‘errno’ error conditions are defined for this
  5945. function:
  5946. ‘EINVAL’
  5947. The value of the PARAMETER is invalid.
  5948. 
  5949. File: libc.info, Node: Constants for Sysconf, Next: Examples of Sysconf, Prev: Sysconf Definition, Up: Sysconf
  5950. 32.4.2 Constants for ‘sysconf’ Parameters
  5951. -----------------------------------------
  5952. Here are the symbolic constants for use as the PARAMETER argument to
  5953. ‘sysconf’. The values are all integer constants (more specifically,
  5954. enumeration type values).
  5955. ‘_SC_ARG_MAX’
  5956. Inquire about the parameter corresponding to ‘ARG_MAX’.
  5957. ‘_SC_CHILD_MAX’
  5958. Inquire about the parameter corresponding to ‘CHILD_MAX’.
  5959. ‘_SC_OPEN_MAX’
  5960. Inquire about the parameter corresponding to ‘OPEN_MAX’.
  5961. ‘_SC_STREAM_MAX’
  5962. Inquire about the parameter corresponding to ‘STREAM_MAX’.
  5963. ‘_SC_TZNAME_MAX’
  5964. Inquire about the parameter corresponding to ‘TZNAME_MAX’.
  5965. ‘_SC_NGROUPS_MAX’
  5966. Inquire about the parameter corresponding to ‘NGROUPS_MAX’.
  5967. ‘_SC_JOB_CONTROL’
  5968. Inquire about the parameter corresponding to ‘_POSIX_JOB_CONTROL’.
  5969. ‘_SC_SAVED_IDS’
  5970. Inquire about the parameter corresponding to ‘_POSIX_SAVED_IDS’.
  5971. ‘_SC_VERSION’
  5972. Inquire about the parameter corresponding to ‘_POSIX_VERSION’.
  5973. ‘_SC_CLK_TCK’
  5974. Inquire about the number of clock ticks per second; *note CPU
  5975. Time::. The corresponding parameter ‘CLK_TCK’ is obsolete.
  5976. ‘_SC_CHARCLASS_NAME_MAX’
  5977. Inquire about the parameter corresponding to maximal length allowed
  5978. for a character class name in an extended locale specification.
  5979. These extensions are not yet standardized and so this option is not
  5980. standardized as well.
  5981. ‘_SC_REALTIME_SIGNALS’
  5982. Inquire about the parameter corresponding to
  5983. ‘_POSIX_REALTIME_SIGNALS’.
  5984. ‘_SC_PRIORITY_SCHEDULING’
  5985. Inquire about the parameter corresponding to
  5986. ‘_POSIX_PRIORITY_SCHEDULING’.
  5987. ‘_SC_TIMERS’
  5988. Inquire about the parameter corresponding to ‘_POSIX_TIMERS’.
  5989. ‘_SC_ASYNCHRONOUS_IO’
  5990. Inquire about the parameter corresponding to
  5991. ‘_POSIX_ASYNCHRONOUS_IO’.
  5992. ‘_SC_PRIORITIZED_IO’
  5993. Inquire about the parameter corresponding to
  5994. ‘_POSIX_PRIORITIZED_IO’.
  5995. ‘_SC_SYNCHRONIZED_IO’
  5996. Inquire about the parameter corresponding to
  5997. ‘_POSIX_SYNCHRONIZED_IO’.
  5998. ‘_SC_FSYNC’
  5999. Inquire about the parameter corresponding to ‘_POSIX_FSYNC’.
  6000. ‘_SC_MAPPED_FILES’
  6001. Inquire about the parameter corresponding to ‘_POSIX_MAPPED_FILES’.
  6002. ‘_SC_MEMLOCK’
  6003. Inquire about the parameter corresponding to ‘_POSIX_MEMLOCK’.
  6004. ‘_SC_MEMLOCK_RANGE’
  6005. Inquire about the parameter corresponding to
  6006. ‘_POSIX_MEMLOCK_RANGE’.
  6007. ‘_SC_MEMORY_PROTECTION’
  6008. Inquire about the parameter corresponding to
  6009. ‘_POSIX_MEMORY_PROTECTION’.
  6010. ‘_SC_MESSAGE_PASSING’
  6011. Inquire about the parameter corresponding to
  6012. ‘_POSIX_MESSAGE_PASSING’.
  6013. ‘_SC_SEMAPHORES’
  6014. Inquire about the parameter corresponding to ‘_POSIX_SEMAPHORES’.
  6015. ‘_SC_SHARED_MEMORY_OBJECTS’
  6016. Inquire about the parameter corresponding to
  6017. ‘_POSIX_SHARED_MEMORY_OBJECTS’.
  6018. ‘_SC_AIO_LISTIO_MAX’
  6019. Inquire about the parameter corresponding to
  6020. ‘_POSIX_AIO_LISTIO_MAX’.
  6021. ‘_SC_AIO_MAX’
  6022. Inquire about the parameter corresponding to ‘_POSIX_AIO_MAX’.
  6023. ‘_SC_AIO_PRIO_DELTA_MAX’
  6024. Inquire about the value by which a process can decrease its
  6025. asynchronous I/O priority level from its own scheduling priority.
  6026. This corresponds to the run-time invariant value
  6027. ‘AIO_PRIO_DELTA_MAX’.
  6028. ‘_SC_DELAYTIMER_MAX’
  6029. Inquire about the parameter corresponding to
  6030. ‘_POSIX_DELAYTIMER_MAX’.
  6031. ‘_SC_MQ_OPEN_MAX’
  6032. Inquire about the parameter corresponding to ‘_POSIX_MQ_OPEN_MAX’.
  6033. ‘_SC_MQ_PRIO_MAX’
  6034. Inquire about the parameter corresponding to ‘_POSIX_MQ_PRIO_MAX’.
  6035. ‘_SC_RTSIG_MAX’
  6036. Inquire about the parameter corresponding to ‘_POSIX_RTSIG_MAX’.
  6037. ‘_SC_SEM_NSEMS_MAX’
  6038. Inquire about the parameter corresponding to
  6039. ‘_POSIX_SEM_NSEMS_MAX’.
  6040. ‘_SC_SEM_VALUE_MAX’
  6041. Inquire about the parameter corresponding to
  6042. ‘_POSIX_SEM_VALUE_MAX’.
  6043. ‘_SC_SIGQUEUE_MAX’
  6044. Inquire about the parameter corresponding to ‘_POSIX_SIGQUEUE_MAX’.
  6045. ‘_SC_TIMER_MAX’
  6046. Inquire about the parameter corresponding to ‘_POSIX_TIMER_MAX’.
  6047. ‘_SC_PII’
  6048. Inquire about the parameter corresponding to ‘_POSIX_PII’.
  6049. ‘_SC_PII_XTI’
  6050. Inquire about the parameter corresponding to ‘_POSIX_PII_XTI’.
  6051. ‘_SC_PII_SOCKET’
  6052. Inquire about the parameter corresponding to ‘_POSIX_PII_SOCKET’.
  6053. ‘_SC_PII_INTERNET’
  6054. Inquire about the parameter corresponding to ‘_POSIX_PII_INTERNET’.
  6055. ‘_SC_PII_OSI’
  6056. Inquire about the parameter corresponding to ‘_POSIX_PII_OSI’.
  6057. ‘_SC_SELECT’
  6058. Inquire about the parameter corresponding to ‘_POSIX_SELECT’.
  6059. ‘_SC_UIO_MAXIOV’
  6060. Inquire about the parameter corresponding to ‘_POSIX_UIO_MAXIOV’.
  6061. ‘_SC_PII_INTERNET_STREAM’
  6062. Inquire about the parameter corresponding to
  6063. ‘_POSIX_PII_INTERNET_STREAM’.
  6064. ‘_SC_PII_INTERNET_DGRAM’
  6065. Inquire about the parameter corresponding to
  6066. ‘_POSIX_PII_INTERNET_DGRAM’.
  6067. ‘_SC_PII_OSI_COTS’
  6068. Inquire about the parameter corresponding to ‘_POSIX_PII_OSI_COTS’.
  6069. ‘_SC_PII_OSI_CLTS’
  6070. Inquire about the parameter corresponding to ‘_POSIX_PII_OSI_CLTS’.
  6071. ‘_SC_PII_OSI_M’
  6072. Inquire about the parameter corresponding to ‘_POSIX_PII_OSI_M’.
  6073. ‘_SC_T_IOV_MAX’
  6074. Inquire about the value associated with the ‘T_IOV_MAX’ variable.
  6075. ‘_SC_THREADS’
  6076. Inquire about the parameter corresponding to ‘_POSIX_THREADS’.
  6077. ‘_SC_THREAD_SAFE_FUNCTIONS’
  6078. Inquire about the parameter corresponding to
  6079. ‘_POSIX_THREAD_SAFE_FUNCTIONS’.
  6080. ‘_SC_GETGR_R_SIZE_MAX’
  6081. Inquire about the parameter corresponding to
  6082. ‘_POSIX_GETGR_R_SIZE_MAX’.
  6083. ‘_SC_GETPW_R_SIZE_MAX’
  6084. Inquire about the parameter corresponding to
  6085. ‘_POSIX_GETPW_R_SIZE_MAX’.
  6086. ‘_SC_LOGIN_NAME_MAX’
  6087. Inquire about the parameter corresponding to
  6088. ‘_POSIX_LOGIN_NAME_MAX’.
  6089. ‘_SC_TTY_NAME_MAX’
  6090. Inquire about the parameter corresponding to ‘_POSIX_TTY_NAME_MAX’.
  6091. ‘_SC_THREAD_DESTRUCTOR_ITERATIONS’
  6092. Inquire about the parameter corresponding to
  6093. ‘_POSIX_THREAD_DESTRUCTOR_ITERATIONS’.
  6094. ‘_SC_THREAD_KEYS_MAX’
  6095. Inquire about the parameter corresponding to
  6096. ‘_POSIX_THREAD_KEYS_MAX’.
  6097. ‘_SC_THREAD_STACK_MIN’
  6098. Inquire about the parameter corresponding to
  6099. ‘_POSIX_THREAD_STACK_MIN’.
  6100. ‘_SC_THREAD_THREADS_MAX’
  6101. Inquire about the parameter corresponding to
  6102. ‘_POSIX_THREAD_THREADS_MAX’.
  6103. ‘_SC_THREAD_ATTR_STACKADDR’
  6104. Inquire about the parameter corresponding to
  6105. a ‘_POSIX_THREAD_ATTR_STACKADDR’.
  6106. ‘_SC_THREAD_ATTR_STACKSIZE’
  6107. Inquire about the parameter corresponding to
  6108. ‘_POSIX_THREAD_ATTR_STACKSIZE’.
  6109. ‘_SC_THREAD_PRIORITY_SCHEDULING’
  6110. Inquire about the parameter corresponding to
  6111. ‘_POSIX_THREAD_PRIORITY_SCHEDULING’.
  6112. ‘_SC_THREAD_PRIO_INHERIT’
  6113. Inquire about the parameter corresponding to
  6114. ‘_POSIX_THREAD_PRIO_INHERIT’.
  6115. ‘_SC_THREAD_PRIO_PROTECT’
  6116. Inquire about the parameter corresponding to
  6117. ‘_POSIX_THREAD_PRIO_PROTECT’.
  6118. ‘_SC_THREAD_PROCESS_SHARED’
  6119. Inquire about the parameter corresponding to
  6120. ‘_POSIX_THREAD_PROCESS_SHARED’.
  6121. ‘_SC_2_C_DEV’
  6122. Inquire about whether the system has the POSIX.2 C compiler
  6123. command, ‘c89’.
  6124. ‘_SC_2_FORT_DEV’
  6125. Inquire about whether the system has the POSIX.2 Fortran compiler
  6126. command, ‘fort77’.
  6127. ‘_SC_2_FORT_RUN’
  6128. Inquire about whether the system has the POSIX.2 ‘asa’ command to
  6129. interpret Fortran carriage control.
  6130. ‘_SC_2_LOCALEDEF’
  6131. Inquire about whether the system has the POSIX.2 ‘localedef’
  6132. command.
  6133. ‘_SC_2_SW_DEV’
  6134. Inquire about whether the system has the POSIX.2 commands ‘ar’,
  6135. ‘make’, and ‘strip’.
  6136. ‘_SC_BC_BASE_MAX’
  6137. Inquire about the maximum value of ‘obase’ in the ‘bc’ utility.
  6138. ‘_SC_BC_DIM_MAX’
  6139. Inquire about the maximum size of an array in the ‘bc’ utility.
  6140. ‘_SC_BC_SCALE_MAX’
  6141. Inquire about the maximum value of ‘scale’ in the ‘bc’ utility.
  6142. ‘_SC_BC_STRING_MAX’
  6143. Inquire about the maximum size of a string constant in the ‘bc’
  6144. utility.
  6145. ‘_SC_COLL_WEIGHTS_MAX’
  6146. Inquire about the maximum number of weights that can necessarily be
  6147. used in defining the collating sequence for a locale.
  6148. ‘_SC_EXPR_NEST_MAX’
  6149. Inquire about the maximum number of expressions nested within
  6150. parentheses when using the ‘expr’ utility.
  6151. ‘_SC_LINE_MAX’
  6152. Inquire about the maximum size of a text line that the POSIX.2 text
  6153. utilities can handle.
  6154. ‘_SC_EQUIV_CLASS_MAX’
  6155. Inquire about the maximum number of weights that can be assigned to
  6156. an entry of the ‘LC_COLLATE’ category ‘order’ keyword in a locale
  6157. definition. The GNU C Library does not presently support locale
  6158. definitions.
  6159. ‘_SC_VERSION’
  6160. Inquire about the version number of POSIX.1 that the library and
  6161. kernel support.
  6162. ‘_SC_2_VERSION’
  6163. Inquire about the version number of POSIX.2 that the system
  6164. utilities support.
  6165. ‘_SC_PAGESIZE’
  6166. Inquire about the virtual memory page size of the machine.
  6167. ‘getpagesize’ returns the same value (*note Query Memory
  6168. Parameters::).
  6169. ‘_SC_NPROCESSORS_CONF’
  6170. Inquire about the number of configured processors.
  6171. ‘_SC_NPROCESSORS_ONLN’
  6172. Inquire about the number of processors online.
  6173. ‘_SC_PHYS_PAGES’
  6174. Inquire about the number of physical pages in the system.
  6175. ‘_SC_AVPHYS_PAGES’
  6176. Inquire about the number of available physical pages in the system.
  6177. ‘_SC_ATEXIT_MAX’
  6178. Inquire about the number of functions which can be registered as
  6179. termination functions for ‘atexit’; *note Cleanups on Exit::.
  6180. ‘_SC_XOPEN_VERSION’
  6181. Inquire about the parameter corresponding to ‘_XOPEN_VERSION’.
  6182. ‘_SC_XOPEN_XCU_VERSION’
  6183. Inquire about the parameter corresponding to ‘_XOPEN_XCU_VERSION’.
  6184. ‘_SC_XOPEN_UNIX’
  6185. Inquire about the parameter corresponding to ‘_XOPEN_UNIX’.
  6186. ‘_SC_XOPEN_REALTIME’
  6187. Inquire about the parameter corresponding to ‘_XOPEN_REALTIME’.
  6188. ‘_SC_XOPEN_REALTIME_THREADS’
  6189. Inquire about the parameter corresponding to
  6190. ‘_XOPEN_REALTIME_THREADS’.
  6191. ‘_SC_XOPEN_LEGACY’
  6192. Inquire about the parameter corresponding to ‘_XOPEN_LEGACY’.
  6193. ‘_SC_XOPEN_CRYPT’
  6194. Inquire about the parameter corresponding to ‘_XOPEN_CRYPT’.
  6195. ‘_SC_XOPEN_ENH_I18N’
  6196. Inquire about the parameter corresponding to ‘_XOPEN_ENH_I18N’.
  6197. ‘_SC_XOPEN_SHM’
  6198. Inquire about the parameter corresponding to ‘_XOPEN_SHM’.
  6199. ‘_SC_XOPEN_XPG2’
  6200. Inquire about the parameter corresponding to ‘_XOPEN_XPG2’.
  6201. ‘_SC_XOPEN_XPG3’
  6202. Inquire about the parameter corresponding to ‘_XOPEN_XPG3’.
  6203. ‘_SC_XOPEN_XPG4’
  6204. Inquire about the parameter corresponding to ‘_XOPEN_XPG4’.
  6205. ‘_SC_CHAR_BIT’
  6206. Inquire about the number of bits in a variable of type ‘char’.
  6207. ‘_SC_CHAR_MAX’
  6208. Inquire about the maximum value which can be stored in a variable
  6209. of type ‘char’.
  6210. ‘_SC_CHAR_MIN’
  6211. Inquire about the minimum value which can be stored in a variable
  6212. of type ‘char’.
  6213. ‘_SC_INT_MAX’
  6214. Inquire about the maximum value which can be stored in a variable
  6215. of type ‘int’.
  6216. ‘_SC_INT_MIN’
  6217. Inquire about the minimum value which can be stored in a variable
  6218. of type ‘int’.
  6219. ‘_SC_LONG_BIT’
  6220. Inquire about the number of bits in a variable of type ‘long int’.
  6221. ‘_SC_WORD_BIT’
  6222. Inquire about the number of bits in a variable of a register word.
  6223. ‘_SC_MB_LEN_MAX’
  6224. Inquire about the maximum length of a multi-byte representation of
  6225. a wide character value.
  6226. ‘_SC_NZERO’
  6227. Inquire about the value used to internally represent the zero
  6228. priority level for the process execution.
  6229. ‘SC_SSIZE_MAX’
  6230. Inquire about the maximum value which can be stored in a variable
  6231. of type ‘ssize_t’.
  6232. ‘_SC_SCHAR_MAX’
  6233. Inquire about the maximum value which can be stored in a variable
  6234. of type ‘signed char’.
  6235. ‘_SC_SCHAR_MIN’
  6236. Inquire about the minimum value which can be stored in a variable
  6237. of type ‘signed char’.
  6238. ‘_SC_SHRT_MAX’
  6239. Inquire about the maximum value which can be stored in a variable
  6240. of type ‘short int’.
  6241. ‘_SC_SHRT_MIN’
  6242. Inquire about the minimum value which can be stored in a variable
  6243. of type ‘short int’.
  6244. ‘_SC_UCHAR_MAX’
  6245. Inquire about the maximum value which can be stored in a variable
  6246. of type ‘unsigned char’.
  6247. ‘_SC_UINT_MAX’
  6248. Inquire about the maximum value which can be stored in a variable
  6249. of type ‘unsigned int’.
  6250. ‘_SC_ULONG_MAX’
  6251. Inquire about the maximum value which can be stored in a variable
  6252. of type ‘unsigned long int’.
  6253. ‘_SC_USHRT_MAX’
  6254. Inquire about the maximum value which can be stored in a variable
  6255. of type ‘unsigned short int’.
  6256. ‘_SC_NL_ARGMAX’
  6257. Inquire about the parameter corresponding to ‘NL_ARGMAX’.
  6258. ‘_SC_NL_LANGMAX’
  6259. Inquire about the parameter corresponding to ‘NL_LANGMAX’.
  6260. ‘_SC_NL_MSGMAX’
  6261. Inquire about the parameter corresponding to ‘NL_MSGMAX’.
  6262. ‘_SC_NL_NMAX’
  6263. Inquire about the parameter corresponding to ‘NL_NMAX’.
  6264. ‘_SC_NL_SETMAX’
  6265. Inquire about the parameter corresponding to ‘NL_SETMAX’.
  6266. ‘_SC_NL_TEXTMAX’
  6267. Inquire about the parameter corresponding to ‘NL_TEXTMAX’.