Skip to content

Instantly share code, notes, and snippets.

@yalab
Last active April 15, 2018 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yalab/e0bf3c16f9be78db337d49404b0f10f8 to your computer and use it in GitHub Desktop.
Save yalab/e0bf3c16f9be78db337d49404b0f10f8 to your computer and use it in GitHub Desktop.

別ウインドウの pts を調べる

vagrant@ubuntu-xenial:~$ w
 07:50:17 up 27 min,  3 users,  load average: 1.17, 1.12, 0.95
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
vagrant  pts/0    10.0.2.2         07:23   26:25   0.30s  0.00s /bin/sh -c set 
vagrant  pts/1    10.0.2.2         07:24    1.00s  0.06s  0.00s w
vagrant  pts/2    10.0.2.2         07:25   57.00s  0.04s  0.04s -bash

pts の bash のプロセスIDを調べる

vagrant@ubuntu-xenial:~$ ps ax | grep pts/2
 9045 ?        S      0:00 sshd: vagrant@pts/2
 9046 pts/2    Ss+    0:00 -bash
25543 pts/1    R+     0:00 grep --color=auto pts/2

strace でプロセスにアタッチして別ウインドウの bash でキーボードを叩くと read と write が発生したことがわかる

vagrant@ubuntu-xenial:~$ sudo strace -p 9046
strace: Process 9046 attached
read(0, "a", 1)                         = 1
write(2, "a", 1)                        = 1
read(0, 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment