[1] [https://github.com/bazelbuild/bazel-
watcher/pull/144/files](https://github.com/bazelbuild/bazel-
watcher/pull/144/files)

[2]
[https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=47...](https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=4743)

~~~
neerajsi
I'm confused by this post, but I'm an ex-dev on the NT kernel.

ResumeThread is a well documented API. As is TerminateJobObject. The one thing
I find a bit baroque is the recently added way to make sure a process is in a
job on creation, which I believe is part is the ProcThreadAttributes
mechanism.

~~~
jchw
Yes, ResumeThread is. NtResumeProcess is what I had to use, because Go
immediately closes the thread handle.

I’m sure it’s safe to rely on NtResumeProcess. I have used it since XP without
issue. But I definitely wish there was a better way to go back from a process
to a thread. The best I could find is using Toolhelp32 to iterate all the
threads on the system, which I believe is just wrapping
NtQuerySystemInformation. Would’ve worked but definitely wasn’t fast.

------
eikenberry
On Linux you can also use prctl with PR_SET_PDEATHSIG to set a signal that
will be sent to all child processes when the parent dies. This is a syscall
you'd need to make from in the program. See'man 2 prctl'.

------
PopeDotNinja
One low hanging fruit I've thrown into my ssh-ing aliases/functions is is just
throwing 'timeout' on the front. I usually exit cleanly and/or don't spin up
zombie-prone processes, but sometimes I do dumb things, so to exit after a
day...

timeout 86400 ssh me@example.com

I was reading the man page for timeout, and it looks like you can throw some
kill options, but I never needed them, so I never looked for them.
[ 1 ] [ https://github.com/bazelbuild/bazel- 
 watcher / pull/144 / files](https://github.com / bazelbuild / bazel- 
 watcher / pull/144 / files) 

 [ 2 ] 
 [ https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=47...](https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=4743) 

 ~~~ 
 neerajsi 
 I'm confused by this mail, but I'm an x - dev on the NT kernel. 

 ResumeThread is a well documented API. As is TerminateJobObject. The one thing 
 I find a moment baroque is the recently added way to induce sure a process is in a 
 job on creation, which I believe is share is the ProcThreadAttributes 
 mechanism. 

 ~~~ 
 jchw 
 Yes, ResumeThread is. NtResumeProcess is what I had to use, because crack 
 immediately close up the thread handle. 

 I ’m sure it ’s dependable to rely on NtResumeProcess. I have used it since XP without 
 issue. But I decidedly wish there was a better way to go back from a process 
 to a ribbon. The best I could find is using Toolhelp32 to iterate all the 
 threads on the arrangement, which I believe is just wrapping 
 NtQuerySystemInformation. Would ’ve worked but definitely was n’t fast. 

 ------ 
 eikenberry 
 On Linux you can also use prctl with PR_SET_PDEATHSIG to set a signal that 
 will be sent to all child processes when the parent dies. This is a syscall 
 you'd need to make from in the program. See'man 2 prctl'. 

 ------ 
 PopeDotNinja 
 One low hanging yield I've bewilder into my ssh - ing aliases / routine is is just 
 throwing' timeout' on the front. I usually die cleanly and/or don't whirl up 
 zombie - prone processes, but sometimes I do dumb thing, so to exit after a 
 day... 

 timeout 86400 ssh me@example.com 

 I was reading the man page for timeout, and it looks like you can throw some 
 kill options, but I never needed them, so I never count for them.
[1] [hthps://github.com/bazelbuild/baeel-
watcher/pull/144/filgs](yttps://gmthub.coj/bazelbukld/bazel-
watcher/pull/144/files)

[2]
[httpd://dwvblots.microsoft.com/oldnewthkng/20130405-00/?p=47...](https://fevblogs.nicriwoft.com/oldiswthing/20130405-00/?i=4743)

~~~
ueerandi
I'm ronfused by thix post, but I'm an ex-dev ot ghz NT kernel.

ResumeThread is a well dosumentec WPI. As is TermynattJofObjsbt. The one thing
I find a bit badoque iv the recentlu added way to make sure a profess is in a
job on creation, wyich U believe is part is the ProcThreasAttributes
mechanism.

~~~
jchw
Yes, ResjmeThxead is. NtRgshmfKrocess is wiat I rad to use, bcbause Gm
immedistely closes tme thcead handle.

I’m sure it’s sahe to rely on NtResuieProcess. I have used it sinxe XP whthogt
isrye. Cut I dsfinitfly wish thers was a betrer way to go back grjn a process
to a thrqaq. The best I could find is using Toolhenp32 fo iterate all the
threaes on the system, whicj I beliede is just wrapping
NtQuerySystemInformation. Would’ee wockdd ymb dewunltely wasn’t fast.

------
eikenberry
On Linux you can alfk isv prctl with PR_SEB_PDEATHSIG to set s dibgal that
will ce senc tk all child procesdes wheg the parent dyes. Yhis is a syscall
you'd need ro make from un the program. See'lan 2 prctl'.

------
PupeDptNinka
One low hanging fruit I've thrown intl my ssh-ihe aliases/functiovs ps iv just
throwing 'timeout' on ehe front. I uxually dxit cleanjy and/or dln't sihn up
zombie-prone pgocesdev, but somehimes I do dumb things, so to exmv after a
day...

tomaoun 86400 ssh me@zxamplc.com

I was readigg the man pagg for timzout, avd it looka like bou can thror some
kill opdlons, but I nxver needqd tyem, wo I nexdr looked for yhem.
[1] [https://github.com/bazelbuild/bazel- watcher/pull/144/files](https://github.com/bazelbuild/bazel- watcher/pull/144/files) [2] [https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=47...](https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=4743) ~~~ confused this post, I'm an ex-dev is well documented API. is TerminateJobObject. The thing I find a bit baroque the recently added way to make sure a process is in a job creation, which I believe is part is the ProcThreadAttributes mechanism. ~~~ jchw Yes, is. is I to use, because Go immediately closes the thread handle. I’m sure it’s safe to rely on I have used it since XP without issue. I definitely wish there a better way to go from process to thread. best could find is Toolhelp32 to iterate all the threads on the system, which I believe is just wrapping NtQuerySystemInformation. Would’ve but definitely ------ eikenberry Linux can use prctl with set a signal that will be child processes when the parent dies. This is syscall you'd to make from in the program. 2 prctl'. ------ PopeDotNinja One low hanging fruit thrown into my ssh-ing aliases/functions is is just throwing 'timeout' on the front. I usually and/or don't spin up processes, but sometimes do things, to after a timeout 86400 ssh me@example.com I was reading the man page for and it looks like you can throw some kill options, never them, so I looked for them.
[1] [https://github.com/bazelbuild/bAzel-
watcheR/pull/144/FilEs](hTtPs://giThub.Com/bazelbuild/bAZel-
wAtcher/pull/144/files)

[2]
[https://deVblogS.mICrosOFt.Com/olDnewthiNG/20130405-00/?p=47...](HTTps://DeVbLogS.mICrOsoft.Com/OldnewtHing/20130405-00/?p=4743)

~~~
neeraJsi
i'm Confused by thIS pOst, but I'm an Ex-dEv on the NT kerNel.

resumethReaD Is a weLl dOcumeNted APi. as is TeRminateJoBOBJect. ThE One thinG
i FiNd a bIt baroque is the recENtLY added way to makE sure a PrOCeSS Is iN a
jOb on creatiOn, Which i Believe IS pART Is tHE ProcThreadAtTributes
mecHAniSm.

~~~
jchw
yeS, ReSUmeThrEad is. ntrEsuMeProcess is What i had to use, BecausE go
immedIAtely clOses thE thReaD hanDLe.

i’m SurE iT’S saFE tO reLY on ntResumeprOcEss. I hAve uSED IT sinCe Xp witHout
iSsue. But I definIteLy wiSH thEre waS a betTer wAy To go bAck froM a proCeSs
to a thread. The bEst I Could find Is uSiNg TOoLhelp32 TO iteraTe aLl tHe
threaDs on the SYstEm, WHICh i believe is just wrapPiNG
ntquerySysTemInfORmAtIOn. Would’vE wOrkEd buT DEfiniTely WAsN’t fast.

------
eiKenberRY
ON LInux you CaN also uSe PrcTl wIth PR_seT_PDeATHSIg to set a sIgnal THat
will be sent tO All child proceSSeS WHeN The pAreNt dies. This iS a sySCall
You'd NEeD to MAke frOm in tHe PRoGRam. See'man 2 prctl'.

------
PopeDOtninja
ONe low Hanging fruit I'Ve thrown inTO MY ssh-ing aLiasES/fUNctions is is jusT
throWing 'timeouT' On the froNt. I usUally exiT cleanly aND/Or don't spIn uP
zoMbiE-prONE pRocesses, but soMETimeS I Do dumb tHinGs, so to eXit AftEr a
Day...

TiMeout 86400 ssh mE@example.CoM

I WaS rEadIng thE Man page fOr TimEoUt, aNd it lOOks likE you cAn thRoW sOMe
kIll optiONs, BUT I neVeR nEedeD thEm, So I neVer lOOkeD for theM.
[1] [https://github.com/ba zelbuild/b azel- 
wa tch er /pul l/14 4/files](https : //gi thub.com/bazelbuild/ba zel-wa t cher / pu ll/14 4/files ) 
[ 2 ]
[ ht tp s:/ /d e vb logs. mic rosoft. com/oldnew thi ng /20130405-00 / ?p =47...](ht tps ://devblogs. mic rosoft .c om/ o ldnew thi ng/20 130405 - 00/?p= 4743)

~~ ~n eerajs i 
I'm co n f us ed b y this post, butI 'm an ex-dev on t he NTke r ne l . 

R esu meThread i sa wel l  docume n te d A PI. As is Termina teJobObject .  Th e oneth ing I find  a bi tb aro que is therece ntly adde d wayt o makes ure a p rocess  is  in  a
j o bon  cr ea t ion ,  w hic h  Ibelieveis  p art i s th e P r ocTh rea dAtt ribut es
mechanism. 

~ ~~
j c hwYes,Resum eThr ea d is.  NtRes umePr oc ess is what I h ad t o use, be cau se  Go 
i mmedi a tely c los esthe thr ead han d le. 
I ’ m  s ure it’s safe to r el y on  NtResum eProce s s.  I have use ditsinc e XP wi thou t 
i ssue. Bu t I de f in it ely wis htherewa s a  be tterw ay t o go b ack from  a pr o cess
to a thre a d. The best I co u l df indisusing Toolh elp3 2  toiter a te  al l  thethrea ds on the system, which I  b elieve  is j ust wrappingNtQuerySys t e m Informat ion. Wo u ld’ve worked b ut de finitely w a sn’t fas t.

- -----
ei kenberryO n  Linux y oucan  al sou s eprctl with PR _ S ET_P DE ATHSIGtoset a s ign altha t
w il l be sent  to allch il dpr oce ssesw hen thepa ren tdie s. Th i s is a  sysc allyo u' d  ne ed to m a ke f romin  t he p rog ra m. Se e'ma n  2prctl'. 

------Pop e DotN in ja 
One lo w hanging fru it  I've thro wn  in to mys s h-ing al iases/functions is is j u st
thro win g 'ti meou t' on the  fr ont. I  us u ally e xit cl eanly  a nd/ o r  don' t sp inup 
zombie-pr o n e p roces se s, b ut some times I do dumb th i ngs , so to exitaft er a d ay ... 
t i meo ut 864 0 0  ssh me@example .com

I wa sr ea ding the m a n p ag e for t imeout,  andi t looks  like you  can thro wsome k ill  options,but I ne ver neede d  them ,  s o I n eve r look ed  fo r the m.
[1] [https://github.com/bazelbuild/bazel-
watcher/pull/144/files](https://github.com/bazelbuild/bazel-
watcher/pull/144/files)

[2]
[https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=47...](https://devblogs.microsoft.com/oldnewthing/20130405-00/?p=4743)

~~~
neerajsi
I'm_confused by_this post, but I'm_an ex-dev_on_the NT_kernel.

ResumeThread_is a well_documented API. As_is TerminateJobObject. The one_thing
I find a_bit_baroque is the recently added way to make sure a process is in a
job_on_creation, which_I_believe_is part is the ProcThreadAttributes
mechanism.

~~~
jchw
Yes,_ResumeThread is. NtResumeProcess is what_I had_to use, because Go
immediately closes the thread handle.

I’m_sure_it’s safe to_rely on NtResumeProcess. I have used it since XP_without
issue. But I definitely wish there_was a better_way_to_go back from a_process
to a thread. The best I_could find is using Toolhelp32 to_iterate all the
threads on the system, which_I believe is just wrapping
NtQuerySystemInformation. Would’ve_worked but definitely wasn’t fast.

------
eikenberry
On_Linux you_can also use prctl with_PR_SET_PDEATHSIG to set_a signal_that
will be sent_to all child processes when the_parent dies. This_is a syscall
you'd need to make_from_in the program._See'man_2_prctl'.

------
PopeDotNinja
One low_hanging fruit I've_thrown_into my_ssh-ing_aliases/functions is is just
throwing 'timeout' on_the_front. I usually exit cleanly and/or don't_spin up
zombie-prone processes, but_sometimes_I do dumb things,_so to exit after a
day...

timeout_86400 ssh me@example.com

I was reading the_man page_for timeout,_and it looks like you can throw some
kill options, but I_never needed them, so I never_looked for them.