Operating Systems 2021F Lecture 10

From Soma-notes

Video

Video from the lecture given on October 12, 2021 is now available:

Video is also available through Brightspace (Resources->Class zoom meetings->Cloud Recordings tab)

Notes

Lecture 10
----------

Requests
 - A2: 2, 3, 5, 9
 
Yes, *please* use the code and tools from the tutorials on the assignments.  That's the purpose of the tutorials!

remember . refers to the current director, .. refers to the parent directory, always

In real code, you'd normally use getopt and getenv rather than parse_args and find_env (because the library versions are more robust and offer more features), but you *can* parse command line arguments and environment variables yourself.

Remember NULL in C can be assigned to any pointer, it means
 the zero pointer which stands for an invalid pointer
  - no way to point to address 0
  - '\0' is kind of the same thing, but you'd have to
    cast it to a pointer.  You never have to cast NULL

What is the difference between a script and a program?
 - both can be run with execve
 - but, with a binary program, just the code of the
   program is loaded into the process
 - with a script, an interpreter is specified in the first line
   with #!, *that* is the program that is loaded, and it is
   given an argument, the script to run

Note that with killsnoop, we're only seeing calls to the kill system call
 - many signals are generated by the kernel without going through kill (the kernel doesn't need to make a system call itself to do something)
    - e.g., SIGCHLD

So programs don't have to turn keystrokes into signals
 - they can just parse it
 - top has set its own handlers for control characters
    - so Ctrl-C doesn't generate a signal

In userspace, to send a signal you use the kill system call
 - but the kernel uses signals for other things

in killsnoop
 - PID is the process sending the signal
 - TPID is the process that will receive the signal
    T = target