File I/O Examples
|
- Echo
It reads lines from stdin and writes to stdout.
- File copy
It creates a copy of an existing file.
- File append
It appends a file at the end of another file.
- seekout - an example of lseek
An example of lseek, creates null bytes by seeeking beyond the end of the file.
-
myls0.c
myls1.c
myls2.c
myls3.c
myls4.c
myls5.c
mylsFinal.c
Example of opendir and readdir to list a directory's content. stat call, ctime, getpwuid, getgrgid
- statdemo.c
Getting sum of all files in a directory using stat.
- lstatdemo.c
Prints file type (dir, reg, lnk) for each file in a directory
- dupdemo.c
Using dup to redirect output from a file to standard output.
- makdir.c Make a new directory
- r
mvdir.c Remove a directory
- rmvfile.c Remove a file
- changedir.c
Change the current working directory of the process
executing this code
-
pwdir.c
getcwd.c Print current working directory
- myfind.c
A simple version of "find" program to find in a specified directory
all files whose names contain a given string. NOTE: No wildcards
accepted.
- If you execute as "myfind dirname hel"
- It
will find files with names such as hello.c, help.txt, shell.txt,
if present in the directory tree specified by "dirname". Their names
contain string "hel".
-
linkinfo.c
This program reads all entries in a given directory, and
for each symbolic link in the directory, it prints the link
information, i.e. the path information contained in the link.
This program makes use of the system call function readlink().
-
makelink.c
This program creates a new symbolic link (path name) for an existing
file. It uses system call function symlink(). This program is
similar to "ln -s" for creating a symbolic link.
- fmtout.c Examples for formatted output
- fmtinput.c Examples for formatted input.
citylist Examples of input for the formatted input example program.
- timeinfo.c This example shows how
to use strftime(0 function to generate current date time in a
desired format such as MONTH-DD-YYYY-HH-MM-SS, e.g.
Feb-13-2013-16-59-08
|
Process Management
|
-
Description of various examples
in this section
-
printpid.c Print process id, parent process id, user id.
- process-chain.c Example of repeated fork calls to create a chain of parent-child. Example 2.5 from the book.
- process-fan.c Example 2.6 from the book.
- process-tree.c Example 2.7 from the book.
-
Example 1 Example of fork-exec using execl.
- Example 2 Example of fork-exec using execv.
- Example 3
Example of fork-exec in which the child executes a shell command
-
Example 4 Example of fork-exec
- parent waits for child finish and return its PID as status
-
Example 5 Parent opens the
file with name "input",
-
creates a child, across the fork child and parent will share the
file descriptor
-
both child and parent read from the same descriptor and the output
gets interleaved by the outputs of the two
-
Example 6 Parent
creates the child and uses the WNOHANG option of waitpid.
Parent is not blocked in wait.
-
Pipeline Example of creating a pipe between two processes.
-
Exit status of a child process Example of how a process obtains exit status of its child.
|
Examples
of POSIX Thread Programming
|
|
Concurrent Programming
|
|
Examples of SYSTEM V Semaphores
|
|
Signal Management
|
|
String Manipulation
|
|
Dynamic Memory
|
|