Kevin Sooter - Processes#373
Open
kevin-sooter wants to merge 8 commits intobloominstituteoftechnology:masterfrom
Open
Kevin Sooter - Processes#373kevin-sooter wants to merge 8 commits intobloominstituteoftechnology:masterfrom
kevin-sooter wants to merge 8 commits intobloominstituteoftechnology:masterfrom
Conversation
codejoncode
reviewed
Feb 20, 2019
codejoncode
left a comment
There was a problem hiding this comment.
if (rc < 0)
{ // fork failed; exit
fprintf(stderr, "fork failed\n");
exit(1);
}
Nice!!! Good thinking prepared for even an error.
codejoncode
reviewed
Feb 20, 2019
There was a problem hiding this comment.
For ex4, you are getting in done Kevin. We will disuss this more in detail tomorrow but we can also accept arguments like this:
int main(int argc, char* argv[])
{
printf("Parent process here\n");
int rc = fork();
if (rc < 0) {
fprintf(stderr, "fork failed\n");
exit(1);
} else if (rc == 0) {
printf("Child process here\n");
// execl("/bin/ls", "ls", "-l" (char *) NULL);
// char *args[] = {"ls", "-l", NULL};
// execv("/bin/ls", args);
//execlp("ls", "ls", "-l", (char *) NULL);
char *args[] = {"ls", "-l", NULL};
execvp("ls", args);
} else {
int wc = waitpid(rc, NULL, 0);
}
return 0;
}
This way we would then pass "/bin/ls"
|
The biggest difference is we could replace |
codejoncode
reviewed
Feb 21, 2019
codejoncode
left a comment
There was a problem hiding this comment.
For ex6 Kevin you have fileno(stdout); is what the solution has for this line write(fileno(stdout), NULL, 0); though you may not notice a difference in your output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.