{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/10420","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/10420/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/10420/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/10420/events","html_url":"https://github.com/JuliaLang/julia/issues/10420","id":60109526,"number":10420,"title":"pid of child Process","user":{"login":"StefanKarpinski","id":153596,"avatar_url":"https://avatars.githubusercontent.com/u/153596?v=3","gravatar_id":"","url":"https://api.github.com/users/StefanKarpinski","html_url":"https://github.com/StefanKarpinski","followers_url":"https://api.github.com/users/StefanKarpinski/followers","following_url":"https://api.github.com/users/StefanKarpinski/following{/other_user}","gists_url":"https://api.github.com/users/StefanKarpinski/gists{/gist_id}","starred_url":"https://api.github.com/users/StefanKarpinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/StefanKarpinski/subscriptions","organizations_url":"https://api.github.com/users/StefanKarpinski/orgs","repos_url":"https://api.github.com/users/StefanKarpinski/repos","events_url":"https://api.github.com/users/StefanKarpinski/events{/privacy}","received_events_url":"https://api.github.com/users/StefanKarpinski/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/intro%20issue","name":"intro issue","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-06T14:38:56Z","updated_at":"2015-12-08T16:21:00Z","closed_at":null,"body":"We don't currently expose any way of getting the PID of a child process. Arguably, this is a system-level detail that we may not want people to program to, but it should be possible to get. Currently, on a 64-bit system you can do this:\r\n\r\n```jl\r\nfunction pid(proc::Base.Process)\r\n    proc.handle != C_NULL || error(\"process not running\")\r\n    int(unsafe_load(convert(Ptr{Uint32}, proc.handle + 72)))\r\nend\r\n```\r\n\r\nObviously not ideal. This also errors if the process has already finished when you call it, which can be unpredictable. What's a good API to this? Should we fold `getpid` into it as a zero-argument version?"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/162934112","html_url":"https://github.com/JuliaLang/julia/issues/10420#issuecomment-162934112","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/10420","id":162934112,"user":{"login":"colbec","id":14130995,"avatar_url":"https://avatars.githubusercontent.com/u/14130995?v=3","gravatar_id":"","url":"https://api.github.com/users/colbec","html_url":"https://github.com/colbec","followers_url":"https://api.github.com/users/colbec/followers","following_url":"https://api.github.com/users/colbec/following{/other_user}","gists_url":"https://api.github.com/users/colbec/gists{/gist_id}","starred_url":"https://api.github.com/users/colbec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colbec/subscriptions","organizations_url":"https://api.github.com/users/colbec/orgs","repos_url":"https://api.github.com/users/colbec/repos","events_url":"https://api.github.com/users/colbec/events{/privacy}","received_events_url":"https://api.github.com/users/colbec/received_events","type":"User","site_admin":false},"created_at":"2015-12-08T16:21:00Z","updated_at":"2015-12-08T16:21:00Z","body":"@vtjnash asked why we need the pid. From a beginner perspective, there appears to be a need to launch and control long lasting processes such as a socket server in the background and then access it from the current Julia instance. We need to verify that it is properly running and (if necessary) later kill it via the pid if it does not want to go away when instructed. This is perhaps not a sophisticated approach to the issue - there may be a better Julia way of achieving this. I searched the docs but did not find anything obvious. run(...) does not expose any later access to the process it launches, and the @sync and @spawn family of routines don't seem to apply. In other applications I have parsed the output of ps to get the pid if necessary. This may be one case of how beginners think in terms of pids, perhaps erroneously."}}