Expected shell to be a long-running process, but it exited... Test failed

I’m stuck on Stage #CZ2. I have implemented the correct solution, but my terminal process seems to exit abruptly, which is causing an issue for the tester.

I’ve tried setting my debug value to true in the .yml file, but that hasn’t made a difference.

Here are my logs:

⚡ This is a turbo test run. https://codecrafters.io/turbo

Running tests. Logs should appear shortly...

[compile] Moved ./.codecrafters/run.sh → ./your_program.sh
[compile] Compilation successful.

Debug = true

[tester::#CZ2] Running tests for Stage #CZ2 (Handle missing commands)
[tester::#CZ2] Running ./your_program.sh
[your-program] $ 
[tester::#CZ2] > nonexistent
[your-program] nonexistent: command not found
[tester::#CZ2] Expected shell to be a long-running process, but it exited
[tester::#CZ2] Test failed

Here is my C code:

#include <stdio.h>
#include <string.h>

int main() {
  // Uncomment this block to pass the first stage
  printf("$ ");
  fflush(stdout);

  // Wait for user input
  char input[100];
  fgets(input, 100, stdin);

  input[strlen(input) - 1] = '\0';
  printf("%s: command not found", input);
}

@james-clarke Thanks for highlighting this! We’ll fix it and get back to you as soon as possible.

In the meantime, adding a newline \n at the end of your output should pass this stage.

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