1

Okay so this is a strange error to describe so bear with me.

I'm currently working on an assignment that requires me to use the Python os module to test Linux processes.

Since my laptop is running windows 10 and all my Linux VMs have miraculously stopped booting I tried using a SSH to a linux machine and the Ubuntu subsystem on my own machine to run this block of code:

    import os
    pid = os.fork()
    if pid == 0: # the child
        print("this is the child")

Here is a screenshot of the resulting error on the linux subsystem: (The same shows up for SSH)

error screenshot

Now the interesting thing is after I type the second line the 'if' statement is automatically indented with the double '>>> >>>' and I have to press each key sever times before it is displayed in the console.

Any advice would be helpful on what could cause this.

0

1 Answer 1

1

This won't work from the interactive Python interpreter.

As you noticed, when you execute os.fork(), you're forking the interactive interpreter itself, that's why you get two >>> prompts and the input looks garbled probably related to both interpreters trying to get the input at the same time.

This should work from a script file executed without using the interactive environment.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a million, it all makes sense now! Saving it to a file and running that file from the command line worked like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.