{"action":"created","issue":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2511","labels_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2511/labels{/name}","comments_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2511/comments","events_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2511/events","html_url":"https://github.com/fish-shell/fish-shell/issues/2511","id":114217445,"number":2511,"title":"echo $$ in bash and echo %self in fish are really the same?","user":{"login":"c02y","id":2135996,"avatar_url":"https://avatars.githubusercontent.com/u/2135996?v=3","gravatar_id":"","url":"https://api.github.com/users/c02y","html_url":"https://github.com/c02y","followers_url":"https://api.github.com/users/c02y/followers","following_url":"https://api.github.com/users/c02y/following{/other_user}","gists_url":"https://api.github.com/users/c02y/gists{/gist_id}","starred_url":"https://api.github.com/users/c02y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c02y/subscriptions","organizations_url":"https://api.github.com/users/c02y/orgs","repos_url":"https://api.github.com/users/c02y/repos","events_url":"https://api.github.com/users/c02y/events{/privacy}","received_events_url":"https://api.github.com/users/c02y/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fish-shell/fish-shell/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-30T07:34:11Z","updated_at":"2015-11-25T03:59:50Z","closed_at":null,"body":"Recently I was reading the book [The Linux Programming Interface](http://www.man7.org/tlpi/), and I did one practice at page 461 and another one at page 469, if you don't have the book, check the content from http://www.pdfiles.com/pdf/files/English/Operating_Systems/The_Linux_Programming_Interface.pdf, if you want to try it yourself, download the source code for the book and follow the steps in the book.\r\n\r\nThe weird thing is, the practice from page 461 for example, when I used `echo %self` to get the PID of the shell, and then `kill -40 the-PID-in-the-background`, the result of `si_pid` is not the same as the result of `echo %self`. \r\nBut when I'm in bash, and use `echo $$` to get the PID of the shell, and then `kill -40 the-PID-in-the-background`, the result of `si_pid` is exactly the same as the result of `echo $$`.\r\n\r\nSo, how does the difference happen?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/fish-shell/fish-shell/issues/comments/159485414","html_url":"https://github.com/fish-shell/fish-shell/issues/2511#issuecomment-159485414","issue_url":"https://api.github.com/repos/fish-shell/fish-shell/issues/2511","id":159485414,"user":{"login":"c02y","id":2135996,"avatar_url":"https://avatars.githubusercontent.com/u/2135996?v=3","gravatar_id":"","url":"https://api.github.com/users/c02y","html_url":"https://github.com/c02y","followers_url":"https://api.github.com/users/c02y/followers","following_url":"https://api.github.com/users/c02y/following{/other_user}","gists_url":"https://api.github.com/users/c02y/gists{/gist_id}","starred_url":"https://api.github.com/users/c02y/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c02y/subscriptions","organizations_url":"https://api.github.com/users/c02y/orgs","repos_url":"https://api.github.com/users/c02y/repos","events_url":"https://api.github.com/users/c02y/events{/privacy}","received_events_url":"https://api.github.com/users/c02y/received_events","type":"User","site_admin":false},"created_at":"2015-11-25T03:59:50Z","updated_at":"2015-11-25T03:59:50Z","body":"Thank you for the further explanation. You can close it now.\n\n\nOn November 25, 2015 11:18:09 Kurtis Rader <notifications@github.com> wrote:\n\n> @c02y The explanation by @faho is correct. Also, you can verify that %self \n> holds the PID of the shell by doing things like `ps -fp %self` or \n> installing a signal handler and sending that signal:\n>\n> ```\n> $ function --on-signal USR1 my_usr1_handler\n>     echo whoa! received sigusr1\n> end\n> $ kill -usr1 %self\n> $ /bin/kill -usr1 %self\n> ```\n>\n> Do you have further questions? If not then please close this issue.\n>\n> ---\n> Reply to this email directly or view it on GitHub:\n> https://github.com/fish-shell/fish-shell/issues/2511#issuecomment-159475593\n"}}