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

Set the executable name in ensure_sealed() #4

Closed
iliana opened this issue Mar 5, 2020 · 2 comments · Fixed by #8
Closed

Set the executable name in ensure_sealed() #4

iliana opened this issue Mar 5, 2020 · 2 comments · Fixed by #8

Comments

@iliana
Copy link
Member

iliana commented Mar 5, 2020

If/when process_set_argv0 is stabilized, we can modify ensure_sealed to set argv[0], which is a current limitation of pentacle.

Tracking issue: rust-lang/rust#66510

Diff on 5c1b0e0 that works with rustc 1.43.0-nightly (75cf41afb 2020-03-04):

diff --git a/src/lib.rs b/src/lib.rs
index 57ffcb9..886f473 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -19,12 +19,12 @@
 //! }
 //! ```

+#![feature(process_set_argv0)]
 #![deny(
     missing_copy_implementations,
     missing_debug_implementations,
     missing_docs,
-    rust_2018_idioms,
-    unstable_features
+    rust_2018_idioms
 )]
 #![warn(clippy::pedantic)]

@@ -67,9 +67,13 @@ pub fn ensure_sealed() -> Result<()> {
     if is_sealed_inner(&file) {
         Ok(())
     } else {
-        Err(SealedCommand::new(&mut file)?
-            .args(std::env::args_os().skip(1))
-            .exec())
+        let mut command = SealedCommand::new(&mut file)?;
+        let mut args = std::env::args_os().fuse();
+        if let Some(arg0) = args.next() {
+            command.arg0(arg0);
+        }
+        command.args(args);
+        Err(command.exec())
     }
 }

diff --git a/tests/ensure_sealed.rs b/tests/ensure_sealed.rs
index 185d084..bcda8c6 100644
--- a/tests/ensure_sealed.rs
+++ b/tests/ensure_sealed.rs
@@ -12,4 +12,5 @@
 fn main() {
     pentacle::ensure_sealed().unwrap();
     assert_eq!(pentacle::is_sealed(), true);
+    assert!(std::env::args().next().unwrap().contains("ensure_sealed"));
 }
@oblique
Copy link

oblique commented Sep 20, 2020

process_set_argv0 was stabilized in 1.45. Can you apply the patch?

@iliana
Copy link
Member Author

iliana commented Sep 22, 2020

Yes. I'll see if I can do that this week.

@iliana iliana linked a pull request Sep 30, 2020 that will close this issue
@bors bors bot closed this as completed in a4454be Sep 30, 2020
@bors bors bot closed this as completed in #8 Sep 30, 2020
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

Successfully merging a pull request may close this issue.

2 participants