Skip to content

Child process#25

Merged
donovanh merged 16 commits intomasterfrom
child-process
May 3, 2021
Merged

Child process#25
donovanh merged 16 commits intomasterfrom
child-process

Conversation

@readikus
Copy link
Copy Markdown
Collaborator

No description provided.

@readikus readikus marked this pull request as ready for review April 29, 2021 08:13
@readikus readikus added the article Adding content label Apr 29, 2021
Copy link
Copy Markdown
Collaborator

@donovanh donovanh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good - I've just thrown in some nitpicks

Comment thread child-processes/index.md Outdated
---

Coming soon.
<<<<<<< HEAD
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some merge artefact

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted

// optional - there is no reason why this child process
// can't be called multiple times.
process.exit()
})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this code have semi-colons?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted!

Comment thread child-processes/fork-parent.js Outdated

const child1 = fork('fork-child')
const child2 = fork('fork-child')
const child3 = fork('fork-child')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semi-colons missing but present elsewhere

Comment thread child-processes/index.md
## A Simple `exec`

In this example, we will call the `ls` command to listwith the optional param `-l` to show a long list of details.
<div class="repl-code">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nitpick: I'd adda line before the HTML code here to make it easier to scan

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread child-processes/index.md Outdated

## A Simple `exec`

In this example, we will call the `ls` command to listwith the optional param `-l` to show a long list of details.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is listwith a thing? :D

Comment thread child-processes/index.md

```
</div>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe add a quick line saying what exec does here - may seem obvious but I think it helps to reinforce the point.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just pushed

Comment thread child-processes/index.md Outdated
```
</div>

In this example we are listening to the `stout` and `stderr` streams for `data` events, as well as listening for a `close` event.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these events different from the exec approach?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - exec buffers it to strints

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strings.

I'll add that :)

Comment thread child-processes/index.md Outdated

# fork

`fork` is a special version of `spawn' that allows messages to be sent between the Node processes.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spawn' -> spawn`

Comment thread child-processes/index.md Outdated

Parents `spawm`, `fork` or `exec` child processes, and communicate via events or pipes.

Take me to [cheat sheet]({{ "/cheatsheet/#child-process" | url }})
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd stick a full stop after the link here :)

Comment thread child-processes/index.md

## Exercise

Create a child process for doing some manipulation of a file or URL, and build a parent process that controls a number of these processes in parallel.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have a hidden suggested-solution? If too much to do, we can leave it for now.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - I think there is more value in populating the other bits of content and we can come back to this, or maybe I can put a note in for someone to do one and put it up as a PR :)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comment - thanks for all the comments and keeping me honest. Made a big improvement to this piece.

Copy link
Copy Markdown
Collaborator

@donovanh donovanh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give this a whirl. Good job

@donovanh donovanh merged commit e280b73 into master May 3, 2021
@donovanh donovanh deleted the child-process branch May 3, 2021 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

article Adding content

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants