-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugcurrentexe: command to show the path to the main executable
Summary: This command prints the path to the main executable. It's similar to `sys.executable` in `debugshell`, but without using Python. The main motivation is to better support the node IPC channel on Windows. The problem is that by default, libc (CRT, C runtime) fds (not confused with Windows OS handles) are *not* inherited. To inherit them you'll need to set the `lpReserved2` in `STARTUPINFOA` struct when creating a process. The field is [documented](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa) as: cbReserved2 Reserved for use by the C Run-time; must be zero. lpReserved2 Reserved for use by the C Run-time; must be NULL. Rust stdlib does not provide a way to set them in the C runtime compatible way to pass C fds. nodejs/libuv sets them directly, ignoring the "must be NULL" suggestions. On Windows, there are multiple layers of wrappers today. For the telemetry wrapper we might teach it to translate the fd to Windows HANDLE and teach the main binary to also accept a HANDLE. Reviewed By: sggutier Differential Revision: D50020026 fbshipit-source-id: 1798a30848b2b76add63f5637594784e6e7e096c
- Loading branch information
1 parent
98732c7
commit 4272035
Showing
4 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This software may be used and distributed according to the terms of the | ||
* GNU General Public License version 2. | ||
*/ | ||
|
||
use clidispatch::ReqCtx; | ||
|
||
use super::ConfigSet; | ||
use super::NoOpts; | ||
use super::Result; | ||
|
||
pub fn run(ctx: ReqCtx<NoOpts>, _config: &mut ConfigSet) -> Result<u8> { | ||
let path = std::env::current_exe()?; | ||
let out = format!("{}\n", path.display()); | ||
ctx.io().write(out)?; | ||
Ok(0) | ||
} | ||
|
||
pub fn aliases() -> &'static str { | ||
"debugcurrentexe" | ||
} | ||
|
||
pub fn doc() -> &'static str { | ||
"show the path to the main executable" | ||
} | ||
|
||
pub fn synopsis() -> Option<&'static str> { | ||
None | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters