public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: jmr@ugcs.caltech.edu To: gcc-gnats@gcc.gnu.org Subject: libgcj/7570: Runtime.exec with null envp: child doesn't inherit parent env Date: Sun, 11 Aug 2002 00:26:00 -0000 [thread overview] Message-ID: <200208102136.g7ALaNB23921@churchill.internal.avlsi.com> (raw) >Number: 7570 >Category: libgcj >Synopsis: Runtime.exec with null envp: child doesn't inherit parent env >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Sat Aug 10 14:46:00 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jesse Rosenstock >Release: 3.3 20020810 (experimental) >Organization: >Environment: System: Linux churchill 2.4.3-12 #1 Fri Jun 8 15:05:56 EDT 2001 i686 unknown Architecture: i686 host: i686-pc-linux-gnu build: i686-pc-linux-gnu target: i686-pc-linux-gnu configured with: ../gcc/configure --enable-languages=c++,java --enable-threads=posix --enable-shared --prefix=/scratch/app/gcc --enable-hash-synchronization : (reconfigured) >Description: Runtime.exec is starting the child with an empty (except for PATH LD_LIBRARY_PATH) environment when passed null for the env argument. Sun's javadoc states: "If envp is null, the subprocess inherits the environment settings of the current process." The libjava javadoc states: "If the environment is null, the process inherits the environment of this process." This does not appear to be happening. >How-To-Repeat: ExecEnv.java: public class ExecEnv { private static void env(String[] envp) throws Exception { Process proc = Runtime.getRuntime().exec("/usr/bin/env", envp, null); int status = proc.waitFor(); byte[] buf = new byte[proc.getInputStream().available()]; proc.getInputStream().read(buf, 0, buf.length); System.out.write(buf, 0, buf.length); } public static void main(String[] args) throws Exception { System.out.println("Results with null env"); env(null); System.out.println(); System.out.println("Results with empty env"); env(new String[0]); System.out.println(); System.out.println("Results with foo env"); env(new String[]{"foo=bar"}); System.out.println(); } } ; javac ExecEnv.java ; java ExecEnv Results with null env STY=9173.pts-4.churchill TERM=vt100 TERMCAP=SC|vt100|VT 100/ANSI X3.64 virtual terminal:\ :DO=\E[%dB:LE=\E[%dD:RI=\E[%dC:UP=\E[%dA:bs:bt=\E[Z:\ :cd=\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\ :do=^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\ :le=^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\ :li#58:co#80:am:xn:xv:LP:sr=\EM:al=\E[L:AL=\E[%dL:\ :cs=\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:dc=\E[P:DC=\E[%dP:\ :im=\E[4h:ei=\E[4l:mi:IC=\E[%d@:ks=\E[?1h\E=:\ :ke=\E[?1l\E>:vi=\E[?25l:ve=\E[34h\E[?25h:vs=\E[34l:\ :us=\E[4m:ue=\E[24m:so=\E[3m:se=\E[23m:mb=\E[5m:\ :md=\E[1m:mr=\E[7m:me=\E[m:ms:\ :Co#8:pa#64:AF=\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\ :vb=\Eg:G0:as=\E(0:ae=\E(B:\ :ac=\140\140aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++,,hhII00:\ :po=\E[5i:pf=\E[4i:k0=\E[10~:k1=\EOP:k2=\EOQ:k3=\EOR:\ :k4=\EOS:k5=\E[15~:k6=\E[17~:k7=\E[18~:k8=\E[19~:\ :k9=\E[20~:k;=\E[21~:F1=\E[23~:F2=\E[24~:F3=\E[25~:\ :F4=\E[26~:F5=\E[28~:F6=\E[29~:F7=\E[31~:F8=\E[32~:\ :F9=\E[33~:FA=\E[34~:kb=^H:K1=\EOw:K2= Results with empty env Results with foo env foo=bar ; gij ExecEnv Results with null env PATH=/home/user/jmr/app/gdb/bin:/home/user/jmr/app/gcc/bin:/home/user/jmr/app/binutils/bin:/home/user/jmr/app/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin:/usr/local/java/bin:/usr/local/java/jre/bin:/usr/local/cad/bin:/usr/bin:/usr/sbin:/usr/X11R6/bin LD_LIBRARY_PATH=/scratch/app/gcc/lib Results with empty env PATH=/home/user/jmr/app/gdb/bin:/home/user/jmr/app/gcc/bin:/home/user/jmr/app/binutils/bin:/home/user/jmr/app/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin:/usr/local/java/bin:/usr/local/java/jre/bin:/usr/local/cad/bin:/usr/bin:/usr/sbin:/usr/X11R6/bin LD_LIBRARY_PATH=/scratch/app/gcc/lib Results with foo env foo=bar PATH=/home/user/jmr/app/gdb/bin:/home/user/jmr/app/gcc/bin:/home/user/jmr/app/binutils/bin:/home/user/jmr/app/bin:/sbin:/bin:/usr/local/bin:/usr/local/sbin:/usr/local/java/bin:/usr/local/java/jre/bin:/usr/local/cad/bin:/usr/bin:/usr/sbin:/usr/X11R6/bin LD_LIBRARY_PATH=/scratch/app/gcc/lib >Fix: Index: java/lang/Runtime.java =================================================================== RCS file: /cvsroot/gcc/gcc/libjava/java/lang/Runtime.java,v retrieving revision 1.11 diff -c -r1.11 Runtime.java *** java/lang/Runtime.java 24 Jul 2002 23:17:39 -0000 1.11 --- java/lang/Runtime.java 10 Aug 2002 21:19:49 -0000 *************** *** 534,541 **** SecurityManager sm = securityManager; // Be thread-safe! if (sm != null) sm.checkExec(cmd[0]); - if (env == null) - env = new String[0]; //XXX Should be: return execInternal(cmd, env, dir); return execInternal(cmd, env); } --- 534,539 ---- >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2002-08-10 21:46 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-08-11 0:26 jmr [this message] 2002-08-13 18:02 tromey
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=200208102136.g7ALaNB23921@churchill.internal.avlsi.com \ --to=jmr@ugcs.caltech.edu \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).