09/30/08 Unix Sys. Prog. Notes
Set userid
effective userid changes
files and devices are similar because devices can be accessed by the entry in the file system
ls -l on devices mode looks like
crw–w—-
c – character special device
b – block special device
crw–w—- 1 jzhou01 tty 136, 17 2008-09-30 18:42 17
two numbers:
first: major device number
second: minor number
two persons can open a file at a time and a lseek to the end may be done before the other one writes something
First person: sheep
Second person: cat
Now: catep
flags fcntl (file_descriptor, F_GETFL)
O_APPEND bit
flags |= O_APPEND
fcntl (fd, f_SETFL, flags);
stty -a
speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?;
swtch = M-^?; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W;
lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts
-ignbrk brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc ixany imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke
input carriage return new line: interpret carriage return as a new line character.
fd = open (“somefile, O_WRONLY | O_APPEND);
pushd
popd
struct termios info;
int rv;
rv = tcgetattr (file_discriptor, &info);
tcsetattr (file_descriptor, TCSANOW, &info);
It’s critical that the terminal buffers the input
Signals cannot be ignored:
Ctrl-Z: Suspend
kill (a mechanism to send a signal, not killing).
kill -KILL 12345