Skip to content
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

Support exec #135

Open
casey opened this issue Jul 29, 2021 · 5 comments
Open

Support exec #135

casey opened this issue Jul 29, 2021 · 5 comments

Comments

@casey
Copy link
Collaborator

casey commented Jul 29, 2021

I'm writing a command wrapper and would like to exec the command I'm running, so that the process tree doesn't show the intermediate wrapper.

I looked in the standard library, and was surprised to see that exec is provided on unix:

https://doc.rust-lang.org/std/os/unix/process/trait.CommandExt.html#tymethod.exec

What do you think about a cmd_exec! macro? The return type would be fixed to io::Error, since in the success case it does not return.

@soenkehahn
Copy link
Owner

Yeah, that seems like a good idea. At least if it's not too complicated to implement. But I don't think it should be.

I wouldn't want to export it by default. But putting it into an e.g. exec submodule sounds fine.

@casey
Copy link
Collaborator Author

casey commented Jul 29, 2021

I wonder if there should be some kind of speedbump to prevent users from using it without realizing that it's platform-dependent, i.e. it doesn't work on windows. The exec function in the standard library is on std::os::unix::process::CommandExt, so perhaps we should mirror that. Maybe define cmd_exec in cradle::os::unix?

@soenkehahn
Copy link
Owner

Yeah, that seems good too.

I had hoped that the generated documentation would show a This is supported on Unix only. label if an item has a #[cfg(unix)]. But that doesn't seem to be the case, at least when building documentation locally. How can we get such a label?

@soenkehahn
Copy link
Owner

Or maybe cradle::unix is good enough? And would make it clearer at the top-level, what's going on.

@casey
Copy link
Collaborator Author

casey commented Jul 29, 2021

I think cradle::unix is probably good. It seems unlikely that we'd have arch-specific stuff, for example, that would make two levels necessary.

I think that you only get that label if you use an attribute like #[doc(cfg(unix))], which seems to be unstable. I only skimmed the issue though, so I could be misunderstanding what that attribute does.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants