The document discusses a CS assignment involving creating a pipe between a parent and child process. The parent writes a message to the pipe and the child reads it and prints it before both processes close their respective ends of the pipe.
The document discusses a CS assignment involving creating a pipe between a parent and child process. The parent writes a message to the pipe and the child reads it and prints it before both processes close their respective ends of the pipe.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3
CS604P Assignment No.
Questions No 01 15 marks
1. Includes: Includes necessary header files for standard input/output, process
control, and error handling. 2. Pipe Creation: Creates a pipe using the pipe() function. A pipe is a unidirectional communication channel between related processes. The pipefd array holds two file descriptors: pipefd[0] for reading and pipefd[1] for writing. 3. Forking: Creates a child process using fork(). The child process inherits a copy of the parent's file descriptors, including the pipe. 4. Child Process: o Closes the write end of the pipe (pipefd[1]) since it will only be reading. o Reads data from the pipe using read(). o Prints the received message. o Closes the read end (pipefd[0]). 5. Parent Process: o Closes the read end of the pipe (pipefd[0]) since it will only be writing. o Prompts the user for a message. o Writes the message to the pipe using write(). o Closes the write end (pipefd[1]). o Waits for the child process to finish using wait(). Questions No 02 5 marks
Linux Command Details
Ls Lists files and directories in the current working directory. Options include: <br> - -l: Long listing format (permissions, ownership, size, modification time)<br> - -a: Lists all files, including hidden files. Cd Changes the current working directory. Example: cd /home/username Grep Searches for patterns in files or input. Example: grep "search_term" filename.txt Cat Concatenates and displays the contents of files. Example: cat file1.txt file2.txt rm or rmdir Deletes files and directories.<br> - rm : Used to delete files. Example: rm file1.txt <br> - rmdir: Used to delete empty directories. Example: rmdir empty_folder drive_spreadsheetExport to Sheets