[nailgun client] Cherry-pick isatty forwarding diff 6f66e4a from upstream
[nailgun client] Cherry-pick isatty forwarding diff 6f66e4a from upstream

Summary:
Buck's detection of when to enable or disable ANSI escape sequences
is based on checking if `System.console()` returns `null`.

This is a bad check for a few reasons:

1) It is based on the state of the JVM when `buckd` was launched, not
the current terminal the `buck` client is connected to, and

2) It means we cannot launch `buckd` with stdio file descriptors closed,
which means `ssh hostname buck build blah` hangs forever waiting for
the `buckd` process to close its stdio file descriptors

To fix this, we need the nailgun client to tell the server whether
its stdio file descripors are connected to TTYs. Luckily, this upstream
diff already implemented exactly that:

https://github.com/martylamb/nailgun/pull/20

This diff cherry-picks that change into our local copy of ng.c.

Test Plan:
buck build buck, added logs to confirm new environment
variables were passed

facebook/buck,janicduplessis/buck,shs96c/buck,illicitonion/buck,vine/buck,brettwooldridge/buck,LegNeato/buck,robbertvanginkel/buck,OkBuilds/buck,nguyentruongtho/buck,shybovycha/buck,pwz3n0/buck,pwz3n0/buck,robbertvanginkel/buck,bocon13/buck,k21/buck,marcinkwiatkowski/buck,daedric/buck,mnuessler/buck,rhencke/buck,janicduplessis/buck,JoelMarcey/buck,rhencke/buck,marcinkwiatkowski/buck,clonetwin26/buck,stuhood/buck,ilya-klyuchnikov/buck,justinmuller/buck,robbertvanginkel/buck,marcinkwiatkowski/buck,Distrotech/buck,luiseduardohdbackup/buck,liuyang-li/buck,shs96c/buck,romanoid/buck,rhencke/buck,shs96c/buck,dsyang/buck,clonetwin26/buck,mikekap/buck,zhuxiaohao/buck,davido/buck,Dominator008/buck,rhencke/buck,darkforestzero/buck,Addepar/buck,sdwilsh/buck,Learn-Android-app/buck,Learn-Android-app/buck,shybovycha/buck,artiya4u/buck,siddhartharay007/buck,zhuxiaohao/buck,MarkRunWu/buck,Dominator008/buck,Learn-Android-app/buck,SeleniumHQ/buck,JoelMarcey/buck,raviagarwal7/buck,Heart2009/buck,dpursehouse/buck,brettwooldridge/buck,darkforestzero/buck,daedric/buck,k21/buck,facebook/buck,dsyang/buck,Learn-Android-app/buck,justinmuller/buck,neonichu/buck,Learn-Android-app/buck,robbertvanginkel/buck,Dominator008/buck,davido/buck,OkBuilds/buck,SeleniumHQ/buck,SeleniumHQ/buck,mnuessler/buck,vschs007/buck,shybovycha/buck,davido/buck,davido/buck,robbertvanginkel/buck,zhuxiaohao/buck,shs96c/buck,stuhood/buck,Heart2009/buck,clonetwin26/buck,Addepar/buck,mikekap/buck,illicitonion/buck,MarkRunWu/buck,zhan-xiong/buck,dushmis/buck,zhuxiaohao/buck,grumpyjames/buck,dsyang/buck,hgl888/buck,zpao/buck,nguyentruongtho/buck,LegNeato/buck,luiseduardohdbackup/buck,Dominator008/buck,Distrotech/buck,shybovycha/buck,raviagarwal7/buck,Learn-Android-app/buck,rmaz/buck,ilya-klyuchnikov/buck,bocon13/buck,tgummerer/buck,pwz3n0/buck,janicduplessis/buck,clonetwin26/buck,sdwilsh/buck,neonichu/buck,liuyang-li/buck,1yvT0s/buck,mikekap/buck,romanoid/buck,marcinkwiatkowski/buck,rmaz/buck,luiseduardohdbackup/buck,davido/buck,LegNeato/buck,clonetwin26/buck,zhan-xiong/buck,grumpyjames/buck,romanoid/buck,OkBuilds/buck,nguyentruongtho/buck,LegNeato/buck,marcinkwiatkowski/buck,Addepar/buck,Heart2009/buck,luiseduardohdbackup/buck,daedric/buck,lukw00/buck,grumpyjames/buck,nguyentruongtho/buck,Distrotech/buck,SeleniumHQ/buck,ilya-klyuchnikov/buck,marcinkwiatkowski/buck,rowillia/buck,MarkRunWu/buck,liuyang-li/buck,dushmis/buck,brettwooldridge/buck,siddhartharay007/buck,grumpyjames/buck,JoelMarcey/buck,zhuxiaohao/buck,zhan-xiong/buck,justinmuller/buck,lukw00/buck,brettwooldridge/buck,Addepar/buck,rowillia/buck,Distrotech/buck,SeleniumHQ/buck,Distrotech/buck,OkBuilds/buck,Distrotech/buck,sdwilsh/buck,illicitonion/buck,bocon13/buck,pwz3n0/buck,LegNeato/buck,rmaz/buck,shybovycha/buck,JoelMarcey/buck,stuhood/buck,kageiit/buck,JoelMarcey/buck,brettwooldridge/buck,shs96c/buck,sdwilsh/buck,ilya-klyuchnikov/buck,zhan-xiong/buck,rmaz/buck,zhan-xiong/buck,marcinkwiatkowski/buck,shybovycha/buck,nguyentruongtho/buck,dpursehouse/buck,ilya-klyuchnikov/buck,marcinkwiatkowski/buck,SeleniumHQ/buck,LegNeato/buck,zhan-xiong/buck,shybovycha/buck,pwz3n0/buck,LegNeato/buck,lukw00/buck,luiseduardohdbackup/buck,1yvT0s/buck,zhuxiaohao/buck,1yvT0s/buck,neonichu/buck,zpao/buck,daedric/buck,davido/buck,dsyang/buck,rowillia/buck,darkforestzero/buck,tgummerer/buck,davido/buck,vine/buck,Addepar/buck,mikekap/buck,romanoid/buck,vschs007/buck,artiya4u/buck,mikekap/buck,dpursehouse/buck,justinmuller/buck,robbertvanginkel/buck,rowillia/buck,tgummerer/buck,hgl888/buck,robbertvanginkel/buck,OkBuilds/buck,illicitonion/buck,SeleniumHQ/buck,Heart2009/buck,dpursehouse/buck,rmaz/buck,zhan-xiong/buck,LegNeato/buck,rowillia/buck,romanoid/buck,OkBuilds/buck,mnuessler/buck,Distrotech/buck,vschs007/buck,justinmuller/buck,SeleniumHQ/buck,neonichu/buck,mogers/buck,davido/buck,ilya-klyuchnikov/buck,sdwilsh/buck,davido/buck,Distrotech/buck,brettwooldridge/buck,dushmis/buck,lukw00/buck,OkBuilds/buck,vine/buck,mogers/buck,mikekap/buck,romanoid/buck,clonetwin26/buck,shs96c/buck,artiya4u/buck,sdwilsh/buck,zhan-xiong/buck,sdwilsh/buck,clonetwin26/buck,SeleniumHQ/buck,dsyang/buck,darkforestzero/buck,bocon13/buck,dpursehouse/buck,raviagarwal7/buck,janicduplessis/buck,justinmuller/buck,rmaz/buck,zhan-xiong/buck,Heart2009/buck,romanoid/buck,ilya-klyuchnikov/buck,sdwilsh/buck,rowillia/buck,k21/buck,stuhood/buck,shybovycha/buck,dsyang/buck,OkBuilds/buck,vine/buck,vine/buck,hgl888/buck,facebook/buck,vschs007/buck,daedric/buck,liuyang-li/buck,mikekap/buck,zpao/buck,rhencke/buck,luiseduardohdbackup/buck,illicitonion/buck,justinmuller/buck,clonetwin26/buck,1yvT0s/buck,bocon13/buck,Heart2009/buck,rowillia/buck,facebook/buck,rowillia/buck,pwz3n0/buck,JoelMarcey/buck,OkBuilds/buck,Addepar/buck,MarkRunWu/buck,JoelMarcey/buck,Dominator008/buck,pwz3n0/buck,shybovycha/buck,clonetwin26/buck,lukw00/buck,siddhartharay007/buck,hgl888/buck,facebook/buck,Dominator008/buck,bocon13/buck,brettwooldridge/buck,tgummerer/buck,hgl888/buck,illicitonion/buck,rmaz/buck,siddhartharay007/buck,MarkRunWu/buck,raviagarwal7/buck,JoelMarcey/buck,sdwilsh/buck,mogers/buck,vine/buck,raviagarwal7/buck,LegNeato/buck,brettwooldridge/buck,luiseduardohdbackup/buck,hgl888/buck,nguyentruongtho/buck,OkBuilds/buck,dsyang/buck,darkforestzero/buck,romanoid/buck,Addepar/buck,vschs007/buck,raviagarwal7/buck,robbertvanginkel/buck,MarkRunWu/buck,marcinkwiatkowski/buck,darkforestzero/buck,janicduplessis/buck,darkforestzero/buck,pwz3n0/buck,stuhood/buck,mikekap/buck,marcinkwiatkowski/buck,stuhood/buck,mogers/buck,grumpyjames/buck,rmaz/buck,ilya-klyuchnikov/buck,illicitonion/buck,ilya-klyuchnikov/buck,SeleniumHQ/buck,marcinkwiatkowski/buck,janicduplessis/buck,shs96c/buck,mnuessler/buck,artiya4u/buck,davido/buck,sdwilsh/buck,Addepar/buck,tgummerer/buck,daedric/buck,hgl888/buck,tgummerer/buck,daedric/buck,LegNeato/buck,mnuessler/buck,stuhood/buck,shs96c/buck,mogers/buck,vschs007/buck,Dominator008/buck,lukw00/buck,liuyang-li/buck,justinmuller/buck,dushmis/buck,Heart2009/buck,artiya4u/buck,raviagarwal7/buck,rmaz/buck,siddhartharay007/buck,siddhartharay007/buck,shs96c/buck,justinmuller/buck,JoelMarcey/buck,1yvT0s/buck,shybovycha/buck,JoelMarcey/buck,davido/buck,janicduplessis/buck,dsyang/buck,k21/buck,shs96c/buck,k21/buck,mikekap/buck,tgummerer/buck,siddhartharay007/buck,Dominator008/buck,Heart2009/buck,nguyentruongtho/buck,clonetwin26/buck,vine/buck,rhencke/buck,shs96c/buck,stuhood/buck,kageiit/buck,robbertvanginkel/buck,zhan-xiong/buck,tgummerer/buck,daedric/buck,vine/buck,robbertvanginkel/buck,stuhood/buck,dpursehouse/buck,zpao/buck,JoelMarcey/buck,dsyang/buck,grumpyjames/buck,vschs007/buck,brettwooldridge/buck,romanoid/buck,Addepar/buck,raviagarwal7/buck,daedric/buck,lukw00/buck,justinmuller/buck,brettwooldridge/buck,illicitonion/buck,1yvT0s/buck,1yvT0s/buck,darkforestzero/buck,SeleniumHQ/buck,mogers/buck,robbertvanginkel/buck,grumpyjames/buck,OkBuilds/buck,dushmis/buck,dpursehouse/buck,illicitonion/buck,romanoid/buck,lukw00/buck,dushmis/buck,ilya-klyuchnikov/buck,artiya4u/buck,hgl888/buck,luiseduardohdbackup/buck,liuyang-li/buck,LegNeato/buck,dsyang/buck,sdwilsh/buck,shybovycha/buck,hgl888/buck,k21/buck,raviagarwal7/buck,zhuxiaohao/buck,Learn-Android-app/buck,MarkRunWu/buck,artiya4u/buck,Addepar/buck,raviagarwal7/buck,stuhood/buck,artiya4u/buck,liuyang-li/buck,k21/buck,neonichu/buck,vschs007/buck,justinmuller/buck,1yvT0s/buck,Dominator008/buck,bocon13/buck,raviagarwal7/buck,rowillia/buck,dushmis/buck,siddhartharay007/buck,kageiit/buck,robbertvanginkel/buck,mnuessler/buck,vschs007/buck,artiya4u/buck,grumpyjames/buck,Distrotech/buck,daedric/buck,facebook/buck,romanoid/buck,siddhartharay007/buck,brettwooldridge/buck,janicduplessis/buck,tgummerer/buck,Learn-Android-app/buck,dsyang/buck,lukw00/buck,janicduplessis/buck,dpursehouse/buck,bocon13/buck,ilya-klyuchnikov/buck,raviagarwal7/buck,darkforestzero/buck,Dominator008/buck,rowillia/buck,romanoid/buck,daedric/buck,vine/buck,Learn-Android-app/buck,marcinkwiatkowski/buck,kageiit/buck,shs96c/buck,Addepar/buck,vschs007/buck,shybovycha/buck,sdwilsh/buck,k21/buck,bocon13/buck,Dominator008/buck,rhencke/buck,neonichu/buck,facebook/buck,mogers/buck,darkforestzero/buck,rmaz/buck,SeleniumHQ/buck,ilya-klyuchnikov/buck,vschs007/buck,illicitonion/buck,k21/buck,dsyang/buck,darkforestzero/buck,dushmis/buck,LegNeato/buck,ilya-klyuchnikov/buck,k21/buck,liuyang-li/buck,mogers/buck,daedric/buck,rmaz/buck,grumpyjames/buck,vschs007/buck,Distrotech/buck,liuyang-li/buck,lukw00/buck,clonetwin26/buck,grumpyjames/buck,rmaz/buck,bocon13/buck,rowillia/buck,brettwooldridge/buck,luiseduardohdbackup/buck,mnuessler/buck,pwz3n0/buck,Dominator008/buck,OkBuilds/buck,tgummerer/buck,liuyang-li/buck,rhencke/buck,grumpyjames/buck,zhan-xiong/buck,mikekap/buck,shs96c/buck,sdwilsh/buck,SeleniumHQ/buck,bocon13/buck,Addepar/buck,janicduplessis/buck,grumpyjames/buck,marcinkwiatkowski/buck,mikekap/buck,artiya4u/buck,MarkRunWu/buck,illicitonion/buck,dsyang/buck,mogers/buck,LegNeato/buck,artiya4u/buck,raviagarwal7/buck,k21/buck,dushmis/buck,Addepar/buck,rmaz/buck,janicduplessis/buck,bocon13/buck,mikekap/buck,clonetwin26/buck,brettwooldridge/buck,zhan-xiong/buck,zhuxiaohao/buck,zpao/buck,shybovycha/buck,daedric/buck,davido/buck,zhuxiaohao/buck,1yvT0s/buck,neonichu/buck,k21/buck,dushmis/buck,JoelMarcey/buck,Heart2009/buck,rowillia/buck,mnuessler/buck,romanoid/buck,clonetwin26/buck,pwz3n0/buck,neonichu/buck,robbertvanginkel/buck,vschs007/buck,tgummerer/buck,mogers/buck,JoelMarcey/buck,mnuessler/buck,liuyang-li/buck,vine/buck,rhencke/buck,Distrotech/buck,OkBuilds/buck,zpao/buck,kageiit/buck,justinmuller/buck,stuhood/buck,vine/buck,lukw00/buck,mogers/buck,Learn-Android-app/buck,kageiit/buck,rhencke/buck,rhencke/buck,justinmuller/buck,k21/buck,pwz3n0/buck,zhan-xiong/buck,neonichu/buck,darkforestzero/buck,zpao/buck,darkforestzero/buck,davido/buck,Learn-Android-app/buck,illicitonion/buck,janicduplessis/buck,kageiit/buck,illicitonion/buck