Python Forum
How to fork a process, kill the child and not kill the parent?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to fork a process, kill the child and not kill the parent?
#1
This post is getting dark.

I have a small gui with tkinter and python 2.7, where I need to execute shutil.copy2(), which can take some time. Obviously, I don't want to block the gui, so I figured I could os.fork() a child process:


pid = os.fork()
if pid == 0:
    shutil.copy2()
    quit() # Kill the child
print "Parent continues..."
That's the general idea. However, what is happening is that when the quit() executes, both child and parent are terminated. Since this is a graphical interface, the mainloop, I expect, would keep the child running if I don't terminate it in some fashion.

I've also tried just creating a new toplevel window for the child, but the copy2() still blocks both the parent and child windows, so that doesn't work either.

How can I kill the child, or am I going about this in the wrong manor?
Reply


Messages In This Thread
How to fork a process, kill the child and not kill the parent? - by neXussT - Mar-04-2017, 02:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Ho can I get the first parent of a class? panoss 2 3,705 Jan-10-2017, 08:10 AM
Last Post: panoss

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020