问题
I'm trying to control the way my cursor looks during certain points of my program execution. To be specific, I want it to be a "spinner" when a Python script is executing, and then a standard pointer when it's done executing. Right now, I have a leave-event-notify callback in Glade that changes the spinner when it leaves a certain area, but this is non-ideal since the user might not know to move the cursor and the cursor doesn't accurately represent the state of the program.
I have my Python program signalling SIGUSR1 at the end of execution. I am spawning the Python script from a C file using GLib's g_spawn_async_with_pipes
. Is there any way to catch a signal from the child process that this creates? Thanks!
回答1:
Pass the G_SPAWN_DO_NOT_REAP_CHILD
flag to g_spawn_async_with_pipes()
and then call g_child_watch_add()
to get a notification when your Python subprocess exits. You don’t need to bother with SIGUSR1
if the process exits when it’s done.
It’s a bit hard to provide a more specific answer unless you post a minimal reproducible example of your code.
来源:https://stackoverflow.com/questions/63250811/catching-signal-from-python-child-process-using-glib