This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SIGTERM does not stop backend postgres processes immediately


To unblock recv() on receipt of a signal -- SIGHUP in particular, for
this test -- I set up a signal handler that calls close() on the
socket fd.  It looks to me like this should call
fhandler_socket::close() on that fd, which then calls closesocket() on
the underlying Win32/winsock SOCKET, which is purported to unblock
the Win32 recv() call on that socket.

But this isn't working because the signal handler function is not
being called directly in response to receipt of SIGHUP.  Using strace
I can see that wait_sig() runs right away but seems to put the signal
in pending state.  It's not until recv() next unblocks due to data
received over the socket that the signal handler function runs,
defeating the whole point.

I've attached some of the relevant strace output to this note.
Process 548 is sending to process 718 over the socket.

-- 
Fred Yankowski           fred@OntoSys.com      tel: +1.630.879.1312
Principal Consultant     www.OntoSys.com       fax: +1.630.879.1370
OntoSys, Inc             38W242 Deerpath Rd, Batavia, IL 60510, USA

--

09:51:11 [main] testrecv 548 cygwin_send: 21 = send (3, 240FE44, 21, 0)
09:51:11 [main] testrecv 718 cygwin_recv: 21 = recv (4, 240FC44, 200, 0)
09:51:11 [main] testrecv 548 sleep: sleep (10)
09:51:14 [sig] testrecv 718 wait_sig: awake
09:51:14 [sig] testrecv 718 wait_sig: processing signal 1
09:51:14 [sig] testrecv 718 wait_sig: Got signal 1
09:51:14 [sig] testrecv 718 sig_handle: signal 1
09:51:14 [sig] testrecv 718 sig_handle: signal 1, about to call 0x4011F8
09:51:14 [sig] testrecv 718 interruptible: h 0x1, interruptible 0
09:51:14 [sig] testrecv 718 proc_subproc: args: 3, 1
09:51:14 [sig] testrecv 718 proc_subproc: clear waiting threads
09:51:14 [sig] testrecv 718 proc_subproc: finished clearing
09:51:14 [sig] testrecv 718 proc_subproc: returning 1
09:51:14 [sig] testrecv 718 setup_handler: armed signal_arrived 0xEC, res 1
09:51:14 [sig] testrecv 718 setup_handler: good.  Didn't suspend main thread, th
 0x6108E72C
09:51:14 [sig] testrecv 718 setup_handler: returning 1
09:51:14 [sig] testrecv 718 sig_handle: returning 1
09:51:14 [sig] testrecv 718 wait_sig: looping
09:51:21 [main] testrecv 548 sleep: 0 = sleep (10)
09:51:21 [main] testrecv 548 cygwin_send: 21 = send (3, 240FE44, 21, 0)
09:51:21 [main] testrecv 718 cygwin_recv: 21 = recv (4, 240FC44, 200, 0)
09:51:21 [main] testrecv 548 sleep: sleep (10)
09:51:21 [main] testrecv 718 reset_signal_arrived: reset signal_arrived
09:51:21 [main] testrecv 718 set_process_mask: old mask = 0, new mask = 1
09:51:21 [main] testrecv 718 _close: close (4)
09:51:21 [main] testrecv 718 _close: 0 = close (4)
09:51:21 [main] testrecv 718 set_process_mask: old mask = 1, new mask = 0
09:51:21 [main] testrecv 718 do_exit: do_exit (0)
09:51:21 [main] testrecv 718 void: 0x0 = signal (20, 0x1)
09:51:21 [main] testrecv 718 void: 0x4011F8 = signal (1, 0x1)
09:51:21 [main] testrecv 718 void: 0x0 = signal (2, 0x1)
09:51:21 [main] testrecv 718 void: 0x0 = signal (3, 0x1)
09:51:21 [main] testrecv 718 fhandler_base::close: handle 0xB4
09:51:21 [main] testrecv 718 proc_terminate: nchildren 0, nzombies 0
09:51:21 [main] testrecv 718 proc_terminate: leaving
09:51:21 [main] testrecv 718 sigproc_terminate: entering
09:51:21 [main] testrecv 718 sigproc_terminate: done
...

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]