Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ctrl-C with cmd /c weirdness #1634

Closed
simonbuchan opened this issue Jan 25, 2017 · 3 comments
Closed

Ctrl-C with cmd /c weirdness #1634

simonbuchan opened this issue Jan 25, 2017 · 3 comments

Comments

@simonbuchan
Copy link

Possibly related to #1569 or #1583.

I see Ctrl-C effectively "background" windows apps launched with cmd.exe /c, that is, it returns to the prompt, but the app continues:

0 app-tester 130 % strace -o node-full.strace /mnt/c/Windows/System32/cmd.exe /c 'node -e "setTimeout(() => console.log(`done`), 3000)"'
done
0 app-tester 0 % strace -o node-intr.strace /mnt/c/Windows/System32/cmd.exe /c 'node -e "setTimeout(() => console.log(`done`), 3000)"'
^C
0 app-tester 130 % done

As far as I can tell, the straces seem as expected?

--- node-full.strace    2017-01-26 12:10:14.746717500 +1300
+++ node-intr.strace    2017-01-26 12:10:23.762533400 +1300
@@ -1,56 +1,53 @@
 execve("/mnt/c/Windows/System32/cmd.exe", ["/mnt/c/Windows/System32/cmd.exe", "/c", "node -e \"setTimeout(() => consol"...], [/* 21 vars */]) = 0
-brk(NULL)                               = 0x7fffd5421000
+brk(NULL)                               = 0x7fffbb78c000
 access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
-mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb2ab30000
+mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3b8aaf0000
 access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
 fstat(3, {st_mode=S_IFREG|0644, st_size=37347, ...}) = 0
-mmap(NULL, 37347, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffb2ab26000
+mmap(NULL, 37347, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f3b8aae6000
 close(3)                                = 0
 access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
 read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\t\2\0\0\0\0\0"..., 832) = 832
 fstat(3, {st_mode=S_IFREG|0755, st_size=1864888, ...}) = 0
-mmap(NULL, 3967392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ffb2a430000
-mprotect(0x7ffb2a5ef000, 2097152, PROT_NONE) = 0
-mmap(0x7ffb2a7ef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7ffb2a7ef000
-mmap(0x7ffb2a7f5000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ffb2a7f5000
+mmap(NULL, 3967392, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f3b8a430000
+mprotect(0x7f3b8a5ef000, 2097152, PROT_NONE) = 0
+mmap(0x7f3b8a7ef000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f3b8a7ef000
+mmap(0x7f3b8a7f5000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f3b8a7f5000
 close(3)                                = 0
-mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb2ab20000
-mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb2ab10000
-mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ffb2ab00000
-arch_prctl(ARCH_SET_FS, 0x7ffb2ab10700) = 0
-mprotect(0x7ffb2a7ef000, 16384, PROT_READ) = 0
-mprotect(0x7ffb2ae09000, 4096, PROT_READ) = 0
-mprotect(0x7ffb2aa25000, 4096, PROT_READ) = 0
-munmap(0x7ffb2ab26000, 37347)           = 0
-getpid()                                = 788
-brk(NULL)                               = 0x7fffd5421000
-brk(0x7fffd5442000)                     = 0x7fffd5442000
+mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3b8aae0000
+mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3b8aad0000
+mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f3b8aac0000
+arch_prctl(ARCH_SET_FS, 0x7f3b8aad0700) = 0
+mprotect(0x7f3b8a7ef000, 16384, PROT_READ) = 0
+mprotect(0x7f3b8ae09000, 4096, PROT_READ) = 0
+mprotect(0x7f3b8aa25000, 4096, PROT_READ) = 0
+munmap(0x7f3b8aae6000, 37347)           = 0
+getpid()                                = 799
+brk(NULL)                               = 0x7fffbb78c000
+brk(0x7fffbb7ad000)                     = 0x7fffbb7ad000
 open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
 fstat(3, {st_mode=S_IFREG|0644, st_size=1668976, ...}) = 0
-mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ffb2a88d000
+mmap(NULL, 1668976, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f3b8a88d000
 close(3)                                = 0
 getcwd("/mnt/c/code/player/app-tester", 4096) = 30
 open("/dev/lxssclient", O_RDWR)         = 3
-ioctl(3, _IOC(0, 0x00, 0x2f, 0x22), 0x7fffdd76eb20) = 0
+ioctl(3, _IOC(0, 0x00, 0x2f, 0x22), 0x7fffc3650210) = 0
 open("/mnt/c/Windows/System32/cmd.exe", O_RDONLY) = 5
-ioctl(3, _IOC(0, 0x00, 0x3f, 0x22), 0x7fffdd76e9e8) = 0
+ioctl(3, _IOC(0, 0x00, 0x3f, 0x22), 0x7fffc36500d8) = 0
 close(5)                                = 0
 open("/mnt/c/code/player/app-tester", O_RDONLY) = 5
-ioctl(3, _IOC(0, 0x00, 0x3f, 0x22), 0x7fffdd76e9e8) = 0
+ioctl(3, _IOC(0, 0x00, 0x3f, 0x22), 0x7fffc36500d8) = 0
 close(5)                                = 0
-ioctl(4, _IOC(0, 0x00, 0x97, 0x22), 0x7fffdd76ea80) = 0
-ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7fffdd76ea78) = 0
-ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7fffdd76ea78) = 0
-ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7fffdd76ea78) = 0
-write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0O\0\0\0\0\0\0\0"..., 223) = 223
-read(4, "\0\0\0\0\0\0\0\0;\0\0\0\0\0\0\0", 16) = 16
-ioctl(4, _IOC(0, 0x00, 0x9b, 0x22), 0x7fffdd76eb18) = 0
-write(4, "\0\0\0\0\0\0\0\0;\0\0\0\0\0\0\0", 16) = 16
-ioctl(5, _IOC(0, 0x00, 0xbf, 0x22), 0x7fffdd76eb10) = 0
-close(3)                                = 0
-close(4)                                = 0
-close(5)                                = 0
-exit_group(0)                           = ?
-+++ exited with 0 +++
+ioctl(4, _IOC(0, 0x00, 0x97, 0x22), 0x7fffc3650170) = 0
+ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7fffc3650168) = 0
+ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7fffc3650168) = 0
+ioctl(4, _IOC(0, 0x00, 0xb7, 0x22), 0x7fffc3650168) = 0
+write(4, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0R\0\0\0\0\0\0\0"..., 223) = 223
+read(4, "\0\0\0\0\0\0\0\0=\0\0\0\0\0\0\0", 16) = 16
+ioctl(4, _IOC(0, 0x00, 0x9b, 0x22), 0x7fffc3650208) = 0
+write(4, "\0\0\0\0\0\0\0\0=\0\0\0\0\0\0\0", 16) = 16
+ioctl(5, _IOC(0, 0x00, 0xbf, 0x22), 0x7fffc3650200) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
+--- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
++++ killed by SIGINT +++

I'm on 15014, and Ctrl-C works as expected with native linux commands.

I also noticed while doing some testing that cmd /c pause doesn't... pause, and cmd /c timeout ... doesn't work at all, but I don't know if that's expected:

0 app-tester 0 % cmd /c pause
Press any key to continue . . . # no keypress!
0 app-tester 0 % cmd /c timeout 1
ERROR: Input redirection is not supported, exiting the process immediately.
0 app-tester 1 %
@benhillis
Copy link
Member

benhillis commented Jan 25, 2017

Thanks for posting - This is a duplicate of #1614.

@simonbuchan
Copy link
Author

@benhillis OK, cool. I did search, but the #1614's title wasn't particularly suggestive of this :) I should probably include closed issues too in the future, which would have found #1574 and saved me some time :)

@benhillis
Copy link
Member

Good call, I've modified #1614's title to include ctrl-c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants