3

I tried calling the os.fork() in the parent() funtion but yet it gives me the same error.

this is my code:

import os

def child():
    print('Hello from child', os.getpid())
    os._exit(0) # else goes back to parent loop

def parent():
    while True:
        newpid = os.fork()
        if newpid == 0:
            child()
        else:
            print('Hello from parent', os.getpid(), newpid)
        if input() == 'q': break

parent()
Nihal
  • 5,262
  • 7
  • 23
  • 41
Bulldog
  • 27
  • 4
  • Probably of interest is the SO question [What's the best way to duplicate fork() in windows?](https://stackoverflow.com/questions/23397/whats-the-best-way-to-duplicate-fork-in-windows) – FlyingTeller Aug 31 '18 at 06:03

1 Answers1

1

os.fork()is only available in Unix. See this.