signal_action does not have effect if S_*_FORCE is used
I am not sure if it is a bug, but calling signal_action with S_IGN has no effect if we make use of "FORCE" signals.
The following will not let my_process run if you replace S_FREEZE by S_FREEZE_FORCE. It works however if you use S_FREEZE.
Begin
...
pid = my_process();
wait_process (pid);
...
End
Process wait_process ( int pid )
Begin
signal_action ( pid, S_FREEZE, S_IGN );
signal ( ALL_PROCESS, S_FREEZE);
Repeat
Frame;
Until ( get_status ( pid ) == 0 )
signal ( ALL_PROCESS, S_WAKEUP );
End
Comments (11)
-
-
repo owner Thanks for reporting, Dario.
Could you please post a complete working example? (imports included). This way we'll be able to trace the issue back.
-
The problem comes from the repeat loop. The "signal(ALL_PROCESS, S_WAKEUP);" line is interpreted without waiting for your loop. This code works :
import "mod_video" import "mod_key" import "mod_text" import "mod_sound" import "mod_wm" import "mod_map" import "mod_draw" import "mod_say" import "mod_file" import "mod_text" import "mod_multi" import "mod_mouse" import "mod_proc" import "mod_screen" import "mod_rand" import "mod_grproc" import "mod_math" import "mod_scroll" import "mod_effects" import "mod_timers" import "mod_mem" import "mod_multi" global int my_process_pid; end begin my_process_pid = my_process(); wait_process(my_process_pid); while(!key(_esc) && !exit_status) frame; end exit(); end process my_process() begin loop say("I'm " + id + " and I'm alive !"); frame; end end process wait_process(int pid) begin signal_action(pid, s_freeze, s_ign); signal(all_process, s_freeze_force); while(get_status(pid) != 0 && !key(_esc)) frame; end signal(all_process, s_wakeup); end
(Sorry for including all the modules :p )
-
reporter Thank you Benjamin for your code example, however I did not understand what you meant with the "the problem is the repeat loop", perhaps I am missing something super easy but cannot see it right now...
Here it comes an example:
#! import "mod_video" import "mod_say" import "mod_proc" import "mod_key" private int my_pid; end begin set_mode ( 320, 240 ); my_pid = my_process (); wait_process ( my_pid ); say ( "This should show up after my_process finishes (press ESC to exit)" ); while ( key ( _esc ) == 0 ) frame; end end process my_process () begin repeat say ( "In a loop (press A to stop)" ); frame; until ( key ( _A ) ) end process wait_process ( int pid ) begin signal_action ( pid, s_freeze, s_ign ); signal ( all_process, s_freeze); say ( get_status ( pid ) ); while ( get_status ( pid ) != 0 ) frame; end signal ( all_process, s_wakeup_force); end
Change signal ( all_process, s_freeze); by signal(all_process, s_freeze_force) and you will see that say ( get_status (pid) ) is 4, and I do not understand if it is supposed to be like that because what I expect is that when I set signal_action, pid is going to ignore any S_FREEZE command.
I also tried: * signal_action(pid, s_freeze_force, s_ign) * setting a frame; after signal_action
Perhaps my understanding of the signal function is not complete so please educate me if so :)
-
reporter Benjamin, what I would expect in your code is to repeatedly get "I'm " + id + " and I'm alive !" and I can only see it once! That is the reason to use signal_action on pid, so as the process ignores the "Freezing". Or am I wrong?
-
I think your example is working well, I don't see any bug. When you set signal_action(pid, s_freeze, s_ign), the process will ignore the s_freeze signal. But the s_freeze_force will not be ignored. I think that the force signals can never be ignored. This behavior seems to be correct to me.
-
reporter If forced signals are never to be ignored then there is of course no problem. For me it made sense that forced signals could be ignored as I understand a Force signal as something that is to be sent "immediately" without waiting for the next frame; But perhaps this understanding is wrong.
So the question is: Are Forced signals never to be ignored?
-
I'm agree with you.
I did not understand your first question at first, but now its clear ^^.
In my opinion, PixTudio must have a signal that can affect all the processes whatever theire status.
It can be usefull when you want to freeze all the processes when your application is not focused on Android, and unfreeze them when the application got the focus back.
-
repo owner If I understand correctly, yes. According to the BennuGD Wiki and a post by SplinterGU (who added the S_*_FORCE signals) forced signals can not be ignored.
Please let me know if I can close the bug report.
-
reporter Yes, thank you for the feedback.
-
repo owner - changed status to resolved
- Log in to comment
It works well with my example :