Welcome to the Linux Foundation Forum!

15.2 error

Hello everyone for lab 15.2

We are asked to do this:
for the child process stdio
● has no ability to read STDIN
● redirects its STDERR to the parent process' STDERR
● exposes STDOUT as a readable stream

to do this we I would think that we would use the stdio property
on the options object. and the stdio property might look like this.

stdio: [ 'ignore', 'pipe', 'inherit']

● has no ability to read STDIN
Answer: set the stdin to 'ignore'
● edirects its STDERR to the parent process' STDERR
Answer: set the stderr to 'inherit'
● exposes STDOUT as a readable stream
Answer: set the stdout to 'pipe'

This seems to match what the lab is asking me to do.

Although when I run the test it has the stderr and stdout swapped.

Like it actually want the child process stdout to inherit from the parent process

and vice versa for stderr.

so I switch the two and I get a pass on the test.

Although I got the test to pass I think that either I am missing something or there is some inconsistency between the test and the instructions for the lab.

my test passing solution in its entirety is below although I think that this solution doesn't match the lab's promt.

'use strict'

const { spawn } = require('child_process')

function exercise (command, args) {
  return spawn(command, args, {
    stdio: [ 'ignore', 'inherit', 'pipe']
  })
}

I have experimented with the code by logging out things from the child process using both the stderr and the stdout.

And I have read the options.stdio documentation in the child_process docs from node.js

Can someone please tell me what I am missing?

Answers

  • hey @andrewpartrickmiller

    You're not missing anything you're absolutely right STDERR and STDOUT are the wrong way round. The instructions are being updated to:

    • has no ability to read STDIN
    • redirects its STDOUT to the parent process' STDOUT
    • exposes STDERR as a readable stream

    thanks so much for pointing this out

Categories

Upcoming Training