Information Technology Reference
In-Depth Information
\begin{itemize}
//Createachildprocessasacloneofthecurrentprocess;
//forkreturnstoboththeparentandchild
fork()
//Runtheapplication``prog''inthecurrentprocess
exec(prog,args)
//Tellthekernelthecurrentprocessiscomplete,
//anditsdatastructuresshouldbegarbagecollected
exit()
//Pauseuntilthechildprocesshasexited
wait(process_ID)
//Sendaninterruptof``type''toaprocess
signal(process_ID,type)
//Openafileorhardwaredevice,specifiedby``name'';
//returnsafiledescriptorthatcanbeusedbyothercalls
fd=open(name)
//Createaone-directionalpipebetweentwoprocesses;
//returnstwofiledescriptors,oneforreading,oneforwriting
pipe(fd[2])
//Replacetheto_fdfiledescriptorwithacopyoffrom_fd;
//usedforreplacingstdin/stdout
dup2(from_fd,to_fd)
//Readupto``size''bytesintobuffer,fromthedevice,fileorchannel.
//``read''returnsthenumberofbytesactuallyread;forstreaming
//devicesthiswilloftenbelessthan``size''.
//Forexample,areadfromthekeyboarddevicewillreturnallofitsqueuedbytes.
intread(fd,buffer,size)
//Analogousto``read'',writeupto``size''bytesintokerneloutput
//bufferforadevice,fileorchannel.
//``write''normallyreturnsimmediately,butmaystallifthereis
//nospaceinthekernelbuffer.
intwrite(fd,buffer,size)
//Returnwhenanyofthefiledescriptorsinthearrayhavedataavailabletoberead.
//Returnsthefiledescriptorwiththedata.
fd=select(fd[],number)
//Tellthekerneltheprocessisdonewiththisdevice,file,orchannel.
close(fd)
\end{itemize}
Figure3.7: List of UNIX system calls discussed in this section.
Search WWH ::




Custom Search