These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references.
Students may use these solutions for personal skill-building and practice.
Unethical use is strictly forbidden.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
int main(int argc, char* argv[]) {
if (argc < 3) {
char message[] = "Usage: myCp filename1 filename2\n";
write(2, message, strlen(message));
exit(EXIT_SUCCESS);
}
else {
pid_t fork_return;
int status, ret;
fork_return = fork();
if (fork_return == 0){
printf("In the CHILD process Trying to Copy\n");
printf("Child Process ID: %d, Parent ID: %d, Process Group: %d\n", getpid(),getppid(),getpgid(getpid()));
// execl("/bin/cp","cp","-p","-i",argv[1],argv[2],NULL);
char *cmd[] = {"/bin/cp","-p","-i",argv[1],argv[2],NULL};
execv ("/bin/cp", cmd);
}
else if(fork_return > 0){
This is only a preview of the solution.
Please use the purchase button to see the entire solution.