Re: Re[2]: g_spawn_async_with_pipes and child signals



2010/10/29 Александр Петухов <al_petukhov mail ru>:
> Thu, 28 Oct 2010 11:02:13 +1100 письмо от Lex Trotman <elextr gmail com>:
>> From the traceback below, GIO is using threads to implement
>> asynchronism.  Using sigprocmask and therefore signal() is undefined
>> in a multi-threaded program but probably defaults to applying to the
>> current thread only. Clearly it hasn't blocked the sigint in the
>> thread waiting on the pipe IO.  So that thread received the signal and
>> executed the default action, terminate the process :-(
>> Try blocking sigint very first thing in main(), before any g_* calls,
>> then subsequent threads will inherit the signal mask with sigint
>> blocked.
> Thank you for your answer, Lex.
> I put signal(SIGINT, SIG_IGN) as a first instruction in main(), but
> SIGINT is still passing to IDE process, and moreover - to display manager
> so my X session finishes if I'm not running all this mess under another gdb instance.

Wow, that sounds like something more major is going on, not just a
missed signal.  Or everything is in the one process group, that
happens IIUC when started from the menu not a shell or the shell is in
certain job control modes (can't quite remember exactly).

> Maybe GTK resets handler to SIG_DFL for some reason?

That might be, but I don't know why.  All I have ever noticed is that
it uses SIGPIPE

> I didn't get clearly about threads, signal handler is set for a whole process, isn't it?

Yes it is, but the doco for signal(2) says:

Notes
The effects of this call in a multi-threaded process are unspecified.

I guess the attempt to do it first while the process was single
threaded wasn't enough :-(.

>
>> GDB sends the signal to its child, ie the process its debugging, but
>> signals received by any member go to the whole signal group which by
>> default includes GDB itself and your IDE.

> Here you gave me a point, I attempted out to move gdb to a new process group after spawning (setpgid(gdb_pid, 0)),
> IDE stopped to receive SIGINT, but gdb output was not like any interruption
> really took place: "^done\n&Quit\n", no "*stopped" marker,
> so probably SIGINT was not sent at all to any process

Which group is the process being debugged a part of, maybe it reverts
to the original, not its immediate parent??

>
>> Thats the traceback, whats the error message, I'm assuming something
>> like sigint received??
> Exactly,
> Program received signal SIGINT, Interrupt.
> 0xb7fe2424 in __kernel_vsyscall ()

Did you try --all??

>
> I want be able to interrupt gdb to be able to insert/delete/modify breakpoints while

Yes, understood.

> debugger is running, by the way I'm trying to do it for geany, I saw your name in geany-devel list,
> are you still in business?

Yes, when I have time to do more than just answer mails.  I thought I
recognised the name.  Maybe we should move this thread to the Geany
devel ML since I don't think its GTK specific.

Cheers
Lex

>
> Best regards,
> Alexander
>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]