Skip to content

Overriding environment on Mac OS X works strangely #8482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
catamorphism opened this issue Aug 13, 2013 · 3 comments
Closed

Overriding environment on Mac OS X works strangely #8482

catamorphism opened this issue Aug 13, 2013 · 3 comments
Labels
O-macos Operating system: macOS

Comments

@catamorphism
Copy link
Contributor

Working on rustpkg, I noticed that run::Process::new, and then calling finish_with_output, works strangely if you provide a Some value for the env field of the process options struct. My hypothesis at first was that on OS X, this was effectively extending the environment instead of overwriting the entire environment. However, I think there might be something more that's wrong. Code:

use std::{io, run, str};

fn main() {
    let mut outp = run::Process::new("/bin/echo", [~"monkeybutts"],
            run::ProcessOptions {
            env: Some(&[(~"QUUX", ~"blat")]),
            dir: None,
            in_fd: None,
            out_fd: None,
            err_fd: None
        });
    let rs = outp.finish_with_output();
    io::println(fmt!("output: %s", str::from_bytes(rs.output)));

The resulting executable sometimes prints out "output: monkeybutts" but sometimes prints out just "output:". So the process I'm spawning doesn't use the environment at all, but adding an environment variable still makes it non-deterministically print the wrong result. This doesn't happen if I change the env field to None.

I'm investigating more, just wanted to write this down.

@ghost ghost assigned catamorphism Aug 13, 2013
@catamorphism
Copy link
Contributor Author

After more exploration, I think the problem has to do with the Option<&[(~str, ~str)]> that's a field in the ProcessOptions struct. If I change it to a Option<~[(~str, ~str)]>, I don't see the non-deterministic behavior. I'll try to make a test case that just involves the option-of-a-vector-slice and not process spawning, and then close this.

@catamorphism
Copy link
Contributor Author

Isolated the bug; will open a new issue.

@catamorphism
Copy link
Contributor Author

See #8498

@catamorphism catamorphism removed their assignment Jun 16, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-macos Operating system: macOS
Projects
None yet
Development

No branches or pull requests

1 participant