# Build your own shell: Dual-command pipeline error

**URL:** <https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653>\
**Category:** Challenges\
**Tags:** challenge:shell\
**Created:** [December 14, 2025, 4:27pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653 "2025-12-14T16:27:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stardustpixels](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/stardustpixels/32/21082_2.png) [@Stardustpixels](https://forum.codecrafters.io/u/Stardustpixels)\
**Post date:** [December 14, 2025, 4:27pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/1 "2025-12-14T16:27:48Z")

</div>

I’m stuck on Dual-command pipeline stage. Here are my logs:

```auto
[tester::#BR6] Running tests for Stage #BR6 (Pipelines - Dual-command pipeline)
[tester::#BR6] [setup] export PATH=/tmp/mango/orange/mango:$PATH
[tester::#BR6] Running ./your_program.sh
[tester::#BR6] [setup] echo -e "banana blueberry\norange pear\napple raspberry\nmango pineapple\ngrape strawberry" > "/tmp/fox/file-46"
[your-program] $ cat /tmp/fox/file-46 | wc
[your-program] 5 10 78
[tester::#BR6] ✓ Received expected response
[tester::#BR6] [setup] echo -e "1. blueberry banana\n2. apple raspberry\n3. mango grape" > "/tmp/owl/file-50"
[your-program] $ 
[tester::#BR6] ^ Line does not match expected value.
[tester::#BR6] Expected: "$ tail -f /tmp/owl/file-50 | head -n 5"
[tester::#BR6] Received: "$ "
[tester::#BR6] Assertion failed.
[tester::#BR6] Test failed

```

As far as I understand, what is happening is, that after executing “cat /tmp/fox/file-46 | wc”, forked subprocess “wc” outputs expected output in stdout, tester accepts it and inputs the next command, but since my shell proces waits for children to terminate, “$ “ appears only after tester inputed next commands. Can my assumptions be right?

---

<div class="post-metadata">

**Author:** ![Stardustpixels](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/stardustpixels/32/21082_2.png) [@Stardustpixels](https://forum.codecrafters.io/u/Stardustpixels)\
**Post date:** [December 14, 2025, 4:30pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/3 "2025-12-14T16:30:36Z")

</div>

PS: I disabled built-ins for this stage, but I doubt this matters now, since the test using only external programs

---

<div class="post-metadata">

**Author:** ![natalka1122](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/natalka1122/32/14116_2.png) [@natalka1122](https://forum.codecrafters.io/u/natalka1122)\
**Post date:** [December 14, 2025, 9:14pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/4 "2025-12-14T21:14:24Z")

</div>

Not sure if regular users are welcomed here. But I solved this challenge recently, so my word might be valuable.

1. You’ll deal with built-ins a bit later, wait for it (for me, it was painful)
2. Can you reproduce this issue? Does the cat filename | wc works fine on your machine? Does it work like a real shell?
3. I am not sure about the language you write, but the main thing in my Python was – **to close the input**. It took me a lot of refactorings to get what it mean, so hopefully you’ll get there too.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 14, 2025, 11:49pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/6 "2025-12-14T23:49:41Z")

</div>

Hey @Stardustpixels, could you [upload your code to GitHub](https://docs.codecrafters.io/features/publish-to-github) and share the link? It will be much easier to debug if I can run it directly.

---

<div class="post-metadata">

**Author:** ![Stardustpixels](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/stardustpixels/32/21082_2.png) [@Stardustpixels](https://forum.codecrafters.io/u/Stardustpixels)\
**Post date:** [December 15, 2025, 8:59am UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/8 "2025-12-15T08:59:39Z")

</div>

[GitHub - Stardustpixels/codecrafters-shell-cpp](https://github.com/Stardustpixels/codecrafters-shell-cpp) Here’s it

---

<div class="post-metadata">

**Author:** ![Stardustpixels](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/stardustpixels/32/21082_2.png) [@Stardustpixels](https://forum.codecrafters.io/u/Stardustpixels)\
**Post date:** [December 15, 2025, 9:03am UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/9 "2025-12-15T09:03:38Z")

</div>

Hi, thanks for your reply! @natalka1122

1. Yeah, I don’t really wait for it eagerly haha
2. It does run ok on my machine, but I think the timing might be off if we test automatically.
3. Can you elaborate on that one? I work in c++ using fork()/dup()/close(), but it still seems relevant. Do you mean you close input of shell process when running subprocesses?

---

<div class="post-metadata">

**Author:** ![natalka1122](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/natalka1122/32/14116_2.png) [@natalka1122](https://forum.codecrafters.io/u/natalka1122)\
**Post date:** [December 15, 2025, 10:20am UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/11 "2025-12-15T10:20:40Z")

</div>

@Stardustpixels  
Say you have this pipeline:  
cmd1 | cmd2  
For cmd1 there is no input, no need to close anything.  
When cmd1 ends the job (say it is cat of a file then there is an end, for tail -f there is no possilbe end), cmd2 should be informed that no new data is comming, aka close the input. Otherwise it is stuck forever waiting.

Sorry, donno what is happening under the hood, can only show my python code: [codecrafters-shell-python/app/async\_command\_processor.py at cbe55f98c7b7d75a27eed31b72d85e938cafa7de · natalka1122/codecrafters-shell-python · GitHub](https://github.com/natalka1122/codecrafters-shell-python/blob/cbe55f98c7b7d75a27eed31b72d85e938cafa7de/app/async_command_processor.py#L105-L108)

I ran into the same issue recently, and since I struggled with it myself, I (somewhat egoistically) assume everyone else must be hitting it too 😀

PS: Adding builtins is the best part of this challenge, especially with Multi-command pipelines

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [December 15, 2025, 11:19pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/12 "2025-12-15T23:19:51Z")

</div>

@Stardustpixels I tried running your code against the previous stages, but it’s actually no longer passing a previous stage **#CZ2 (Handle invalid commands)**.

 ![image](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/d/9/d911bd5348503c41449aa11be6e2fbce28b038bb.png)

**Suggestions** :

1. Use [our CLI](https://docs.codecrafters.io/cli/installation) to test against previous stages by running:

```auto
codecrafters test --previous

```

1. Focus on fixing the early stages first, as later stages depend on them.

---

<div class="post-metadata">

**Author:** ![andy1li](https://yyz1.discourse-cdn.com/flex003/user_avatar/forum.codecrafters.io/andy1li/32/10_2.png) [@andy1li](https://forum.codecrafters.io/u/andy1li)\
**Post date:** [January 13, 2026, 12:49pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/14 "2026-01-13T12:49:03Z")

</div>

Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex003/uploads/codecrafters/original/3X/7/0/700657133935c15703e22c7c8870394f6e6dc27d.svg) [@system](https://forum.codecrafters.io/u/system)\
**Post date:** [January 18, 2026, 12:49pm UTC](https://forum.codecrafters.io/t/build-your-own-shell-dual-command-pipeline-error/15653/15 "2026-01-18T12:49:20Z")

</div>

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.
