Operating System/System Programming(Arif Butt) 30

Lec20) Design and Code Of Daemon Processes

A daemon is a system process that provides services to system admin w/o human intervention (cron) , provide services to OS Kernel (paged), or communciate with other porcesses (httpd). It has following characteristics: A daemon is long-lived , often created at system startup and runs until the system is shut down It runs in the backgroudn and has no controlling terminal. The lack of a controlling..

Lec15) Design and Code Of UNIX who Utility , Buffering

default behavior of who is to display a list of currently logged in users, if there are no argument given when executing "who" command. it is basically reading from /var/run/utmp and write on terminal with appropriate format. who process open the file /var/run/utmp read a utmp strcture untill end of file display the requried fields go to step2 close file /var/run/utmp #include #include #include ..

Lec14) Design and Code of UNIX ls Utility

we can iterate directory by looping through readdir() with given pointer stream. #include #include #include #include #include extern int errno; int main(){ printf("Directory scan of /home/: \n"); DIR* dp = opendir("/home"); chdir("/home"); errno = 0; struct dirent* entry; while(1){ entry = readdir(dp); if(entry == NULL && errno != 0){ perror("readdir"); return errno; } if(entry == NULL && errno ..