/********************************************************** // Author: Abdirahim Abdi // Assignment: Lab 2 // Class: CSE 660 - Operating Systems // Description: Operating System Commands // File EE.cpp **********************************************************/ #include #include #include #include #include #include #include using namespace std; /*************************************/ int main() { mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH; bool readNotDone = true; char buffer[1]; int readBuffer, reverseCount = 0; int fileID_XYZ = open("XYZ.txt", mode); lseek(fileID_XYZ, -1, 2); cout << "Process ID EE" << ": " << getpid() << "(CODE EE)" << " - This is what I read from XYZ: \n"; while (readNotDone) { readBuffer = read(fileID_XYZ, &buffer, 1); cout << buffer; reverseCount++; if (reverseCount == 150) { readNotDone = false; } lseek(fileID_XYZ, -2, 1); } cout << "\n\n"; unlink("XYZ.txt"); cout << "Process ID EE" << ": " << getpid() << "(CODE EE)" << " - Deleting XYZ.txt and terminating.\n\n"; exit(0); }