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: Brainstorming a fix for CTRL-C handling in an emacs shell buf fer (non-TTY)


> >I immediately got a SIGINT in the child process, even before its
> >CTRL-C handler got invoked.

> That's a "Windows" SIGINT, which is the only thing that gdb can
> detect.  A Cygwin SIGINT is a different thing entirely.  Since Cygwin
> has the full complement of Windows signals, it uses another complicated
> method for sending signals between processes.

> Running in strace would tell whether you received a SIGINT or not.  You'd
> see the signal_thread responding to a SIGINT.

This is what I get.

Didn't see anything before the ctrl_c_handler output that looked like an
incoming SIGINT from bash.exe.  Also no hit on a serch for "signal_thread".
What is "[unknown (0x7FC)]" indicated.  Could that be the signal thread?

Interestingly, running
"strace ls -lR" the child doesn't get the SIGINT until after it's
ctrl_c_handler runs and it sends itself a SIGINT.  After that it
appears to get the SIGINT properly and then dutifully exits as
expected.  Running the same "ls -lR" without strace it won't
respond at all.

Also interesting that the code inside ls.exe now thinks that
t->getpgid() == myself->pid.  How does that happen?

Why the different behavior when running inside strace?  Can
I even trust the strace output if running inside strace exhibits
different behavior?

$ cd /
$ strace ls -lR

  ... snip

  110 12065524 [main] ls 1516 stat_worker: 32 = file_attributes for
'c:\cygwin\bin\bzip2.exe'
 2581 12068105 [unknown (0x7FC)] ls 1516 isatty: 0 = isatty (0)
  193 12068298 [unknown (0x7FC)] ls 1516 _write: write (1, 0xA017278, 954)
  124 12068422 [unknown (0x7FC)] ls 1516 _write: write fh 0x1A020A64, name
'{stdout}' bg_check 1, bg_eof 0
  125 12068547 [unknown (0x7FC)] ls 1516 fhandler_base::write: binary write
.:
total 1039
drwxr-xr-x   5 tnoble   None        65536 May  8 14:38 bin
drwxr-xr-x   2 tnoble   None         4096 Apr 25 20:33 bin2
-rwxr-xr-x   1 tnoble   None           55 Mar 27 10:32 cygwin.bat
-rw-r--r--   1 tnoble   None          766 Mar 27 10:32 cygwin.ico
drwxr-xr-x   4 tnoble   None         4096 Apr 20 15:31 etc
drwxr-xr-x   7 tnoble   None        49152 Apr 25 13:48 lib
drwxr-xr-x   2 tnoble   None            0 Apr 20 15:32 sbin
-rw-r--r--   1 tnoble   None         2196 Mar 27 10:32 setup.log
drwxr-xr-x   2 tnoble   None            0 Mar 27 10:28 tmp
drwxr-xr-x  15 tnoble   None         4096 Apr 24 16:35 usr
drwxr-xr-x   4 tnoble   None            0 Apr 20 15:35 var

----> this is my printf in ctrl_c_handler: GetConsoleCP=437
----> isatty=0 pid_exists=1 t->getpgid()=1516 myself->pid=1516
----> pgid=1516 ppid=1 progname=c:\cygwin\bin\ls.exe

  116 12068663 [unknown (0x7FC)] ls 1516 fhandler_base::write: 954 = write
(0xA017278, 954)
  103 12068766 [unknown (0x7FC)] ls 1516 _write: 954 = write (1, 0xA017278,
954)
  111 12068877 [unknown (0x7FC)] ls 1516 _kill: kill (-1516, 2)
   99 12068976 [unknown (0x7FC)] ls 1516 kill_pgrp: pid 1516, signal 2

----> this is my printf in ctrl_c_handler: GetConsoleCP=437
----> isatty=0 pid_exists=1 t->getpgid()=1144 myself->pid=1296
----> pgid=1296 ppid=1144 progname=c:\cygwin\bin\strace.exe

----> this is my printf in ctrl_c_handler: GetConsoleCP=437
----> isatty=0 pid_exists=1 t->getpgid()=1144 myself->pid=1144
----> pgid=1144 ppid=1 progname=c:\cygwin\bin\bash.exe


 3405 12072381 [unknown (0x7FC)] ls 1516 kill_pgrp: killing pid 1516, pgrp
1516, p->ctty 1073741824, myself->ctty 1073741824
  367 12072748 [main] ls 1516 fhandler_base::open: (c:\cygwin\bin\bzip2.exe,
0x190000)
299403 12372151 [unknown (0x7FC)] ls 1516 sig_send: pid 1516, signal 2,
its_me 1
  231 12372382 [unknown (0x7FC)] ls 1516 sig_send: Waiting for thiscomplete
0xEC
  336 12372718 [sig] ls 1516 wait_sig: awake
  139 12372857 [sig] ls 1516 wait_sig: processing signal 2
  107 12372964 [sig] ls 1516 wait_sig: Got signal 2
  107 12373071 [sig] ls 1516 sig_handle: signal 2
  512 12373583 [sig] ls 1516 sig_handle: signal 2, about to call do_exit
  365 12373948 [sig] ls 1516 signal_exit: about to call do_exit (10200)
   96 12374044 [sig] ls 1516 do_exit: do_exit (66048)
  106 12374150 [sig] ls 1516 void: 0x0 = signal (20, 0x1)
   96 12374246 [sig] ls 1516 void: 0x0 = signal (1, 0x1)
  103 12374349 [sig] ls 1516 void: 0x0 = signal (2, 0x1)
   94 12374443 [sig] ls 1516 void: 0x0 = signal (3, 0x1)
  104 12374547 [sig] ls 1516 fhandler_base::close: handle 0xC8
  114 12374661 [sig] ls 1516 fhandler_base::close: handle 0xD4
  111 12374772 [sig] ls 1516 fhandler_base::close: handle 0xD0
  140 12374912 [sig] ls 1516 proc_terminate: nchildren 0, nzombies 0
  106 12375018 [sig] ls 1516 proc_terminate: leaving
   94 12375112 [sig] ls 1516 sigproc_terminate: entering
  104 12375216 [sig] ls 1516 sigproc_terminate: done
  234 12375450 [sig] ls 1516 __to_clock_t: dwHighDateTime 0, dwLowDateTime
1402016
  101 12375551 [sig] ls 1516 __to_clock_t: total 00000000 0000008C
  106 12375657 [sig] ls 1516 __to_clock_t: dwHighDateTime 0, dwLowDateTime
901296
   96 12375753 [sig] ls 1516 __to_clock_t: total 00000000 0000005A
  105 12375858 [sig] ls 1516 _pinfo::exit: Calling ExitProcess 66048


--
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]