g_bus_get_sync changes SIGPIPE signal disposition
If I call g_bus_get_sync in a C program on a debian bullseye PC (libglib2.0-0 2.66.8-1), the disposition for the SIGPIPE signal is changed to SIG_IGN.
I see this quote in the GSocket
documentation:
Note that creating a GSocket causes the signal SIGPIPE to be ignored for the remainder of the program. If you are writing a command-line utility that uses GSocket, you may need to take into account the fact that your program will not automatically be killed if it tries to write to stdout after it has been closed.
Does gdbus use GSocket
? If so, I think this side effect should be mentioned in the gdbus documentation.
Example
If I run the following program:
#include <signal.h>
#include <stdio.h>
#include <gio/gio.h>
int main() {
struct sigaction act;
printf("dfl=%p, ign=%p\n", SIG_DFL, SIG_IGN);
sigaction(SIGPIPE, NULL, &act);
printf("before=%p\n", act.sa_handler);
g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
sigaction(SIGPIPE, NULL, &act);
printf("after=%p\n", act.sa_handler);
return 0;
}
(compiled with gcc $(pkg-config --cflags glib-2.0 gio-2.0) main.c $(pkg-config --libs glib-2.0 gio-2.0)
) then it produces the output:
dfl=(nil), ign=0x1
before=(nil)
after=0x1
but I expect:
dfl=(nil), ign=0x1
before=(nil)
after=(nil)
I checked the other signals but it looks like only SIGPIPE is changed.