I start in the Operating Systems module and this question really caught me off guard. These questions have no solution and I do not know what they are used for in the module.
(a) On Windows, start a shell from the command line, for example. cmd. Assuming you are in a directory with certain types of standard document files, for example. .doc, .pdf, .ppt, etc. Just try typing the name of the file itself.
To elaborate, this question assumes that there is a PDF file, for example. U5-UnixProcess.pdf (any PDF file will do), in the same directory and you have a PDF reader. The following example shows how to start a process from a document:
What happens? Which program is running? Is the PDF file being run?
(b) Explain what is the reason for such a feature in Windows.
(c) How come Windows knows what to do with the file? (Hint: use the right mouse button).
(d) Unix has a related feature. Read the execve manpage and explain the feature and how you can use it.
Here are my answers based on my understanding. I've tried to look for answers, but there do not seem to be any sources explaining such delicate issues.
When we type the file name, the command-line shell looks for the file name in the current directory. If it is not found, it will look for the directories listed in the PATH environment variable. Once the file found, it will search the file extension to find out which application handles the file type, which would be the PDF reader if the file extension is .pdf. After that, the application will start as a new process and pass on the file name to it.
Throughout this process, an application capable of handling the file is running and not the file itself.
The command-line shell allows users to access more commands than those provided by their graphical user interface, such as viewing hidden files.
The Windows command line shell is essentially a command line interpreter. This interpreter reads the user's entries and looks for the file in the current directory, identifies its reader with the help of the file extension and calls the reader to read the file.
I mostly copy a segment of TutorialsPoint for this one. I do not really understand the application of "how to use" here.
execve () is a system call that turns the calling process into a new process, and is the signature of
int execve (const char * path, char * const argv, char * const envp)
execve () runs the program pointed to by path. path must be either a binary executable or a script starting with a line of the form "#! interpreter [arg]In the latter case, the interpreter must be a valid path for an executable that is not itself a script, which will be called as an interpreter [arg] file name.
argv is an array of argument strings passed to the new program. envp is an array of strings, typically of the form key = value, that are passed as environment to the new program. Argv and envp must both be terminated with a null pointer. The argument vector and the environment are accessible to the main function of the called program, when it is defined as follows:
main int (int argc, char * argv, char * envp).
Can anyone strengthen my understanding of these topics and maybe point me to sources I can read on?