34 Commits
Author SHA1 Message Date
xtqqczze d2f3f05b38 fix: mismatched_lifetime_syntaxes lint 2026-09-06 10:19:27 +02:00
xtqqczze 092dcf70d8 style: Add newline after inner attribute for readability (#8130)
Add a newline after inner attributes to make it clear that the
attribute applies to the enclosing item rather than the following item.
2026-09-05 15:31:29 +02:00
Anton Novoselov 29d01fc8e5 fix: prevent stack overflow from process tree cycles in build_proc (#7706)
The `build_proc` function in procinfo recursively walks the process
tree to build child process information. If a cycle exists in the
parent PID chain (which can happen on Windows in particular due to PID
reuse or race conditions during process snapshot enumeration),
the recursion never terminates and overflows the stack.

Add a `visited` HashSet to track already-visited PIDs and skip them,
preventing infinite recursion. Applied to all three platforms (Windows,
Linux, macOS)

Fixes #7705
Related: #6671
2026-06-07 08:22:04 +01:00
Wez Furlong 0cd3fe8f97 wezterm-escape-parser: allow building no_std (but with alloc)
This commit makes a number of parts of wezterm's core
parsing functionality no_std compatible, but requiring alloc.

In the no_std environment, several lookup tables that would
normally have been used to accelerate some operations are
not available and we instead fall back to an O(n) operation.
2025-05-10 15:07:20 -07:00
Wez Furlong edcdefda3b workspace-ify the deps
There have been a couple of attempts at this in the past, which
had some usability warts in what I recall as an earlier, less
useful set of features overall.

Whether that was collective misunderstanding at the time, or things
have gotten better since then, now is a good time to adopt the workspace
dep syntax, because wezterm has many crates to keep on top of, and
automation like dependabot can't see a lot of them.

This will help to manage the versions of deps in wezterm centrally.

Let's try this out in CI: the Cargo.lock changes here are minimal
(eliminated a second version of base64 from one crate, terminal_size
from another, and removed an explicit dep on serde_derive) so
hopefully this sails through on !linux.

closes: https://github.com/wezterm/wezterm/pull/6668
2025-02-12 09:43:36 -07:00
Wez Furlong 14d426fea8 add cargo deny config, update lru 2024-05-13 08:29:36 -07:00
crides 217dfb30f5 fix linux divine_process_list
Fixes #4993
2024-02-12 07:38:05 -07:00
Jalil David Salamé Messina d541e2e13d fix(clippy): Remove closures where possible
- Removes closures and function calls for types that implement default:

  ```rust
  // Change
  let _my_str = get_str().unwrap_or(String::new);
  // To
  let _my_str = get_str().unwrap_or_default();
  ```

- Uses the `.cloned()/.copied()` methods where possible
- Use function pointer instead of simple closure

May improve performace, as closures generate more code, and this might
unlock some inlining opportunities.
2023-03-19 08:41:38 -07:00
Jalil David Salamé Messina 191aacc7d7 fix(clippy): Use faster methods on Iterators
- Use `find` instead of `position(..).next()`
- Use `any` instead of `position(..).next().is_some()/.is_none()`
- Use `first/next` instead of `get(0)/nth(0)`
- Prefer `for` loops over `while let` loops on iterators

May improve performance.
2023-03-19 07:29:23 -07:00
Wez Furlong aefbb6b4a0 deps: update ntapi to 0.4
Avoids:

```
warning: the following packages contain code that will be rejected by a future version of Rust: ntapi v0.3.7
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 36`
```
2022-12-30 08:37:53 -07:00
Mikayla Maki 32771eecc6 Rearranged order of trimming and parsing 2022-09-06 20:14:27 -07:00
Mikayla Maki d74cb1b625 Added extra test 2022-09-06 20:14:27 -07:00
Mikayla Maki d7c4898f3d Add tests for sysctl parsing 2022-09-06 20:14:27 -07:00
Mikayla Maki 75a7c38800 Change wording 2022-09-06 20:14:27 -07:00
Mikayla Maki ffae6818ef Fixed small bug in how procinfo reads sysctl KERN_PROCARGS2 2022-09-06 20:14:27 -07:00
K Simmons 6166008b18 Make procinfo's lua dependency optional 2022-09-06 20:14:27 -07:00
Thomas Kilian d7b1ade1ac Added winapi feature "shellapi" to procinfo 2022-06-23 09:08:05 -07:00
Wez Furlong 862dbc604a cut more things over to dynamic 2022-05-18 07:47:39 -07:00
Wez Furlong f587cac145 config: cut over to wezterm-dynamic
Avoid using serde for mapping between Lua and Rust for the `Config`
struct.

This improves the build speed of the config crate by 2x; it goes down
from 30 seconds to 9 seconds on my 5950x.
2022-05-18 07:47:39 -07:00
Wez Furlong f9c4855159 procinfo: windows: tweak and add more tracing
Use an alternative function to query the executable path for
a target process.

Add more tracing.

refs: #1896
2022-04-20 09:43:56 -07:00
Wez Furlong 92893f2a34 procinfo: defend against weird situations on Windows
I've had a couple of deadlock situations when invoking win32 apps
via wsl on my work machine.  In those situations, the process that
we show in the titlebar is a short lived process that has likely
recently terminated, so I suspect something weird about either
dangling references or, given the deadlock-y nature of things,
maybe trying to reference ourselves.

This commit tries to defend against these by:

* Avoiding creating a ProcHandle for our own pid
* Releasing the toolhelper snapshot as soon as we have copied
  out the list of pids that we need

Not sure that this will nail it, but it seems like it can't hurt.
2022-04-19 08:46:32 -07:00
Wez Furlong b2ba7383b0 windows: procinfo: extra defensive coding around reading proc info
Might possibly help with #1699
2022-04-05 08:54:05 -07:00
Wez Furlong e148cfe8e3 procinfo: tidy up windows impl a bit 2022-01-01 10:01:19 -07:00
Wez Furlong 6a7fd37d34 procinfo: add some comments 2022-01-01 09:53:56 -07:00
Wez Furlong 5660942055 procinfo: add windows console field. mux: ignore non-console procs
When considering the fg process, we don't want a newly spawned
notepad.exe to show as the fg process in a cmd/pwsh pane, as it
runs async from the console and isn't attached to it.

We can extract the console handle from the process information and
use a 0 value handle to indicate win32 apps that are not attached
to any console.

We cannot compare console handle values directly: without probing
deeper into the handle we don't know that two differently valued
handles refer to different consoles, because a handle can be
duplicated into another with a different numeric value.
2022-01-01 09:40:18 -07:00
Wez Furlong 8c66d02364 procinfo: fix build on freebsd 2021-12-31 22:50:53 -07:00
Wez Furlong 20d9ded070 procinfo: add some comments! 2021-12-31 22:49:08 -07:00
Wez Furlong ed958160f3 procinfo: fixup macos build 2021-12-31 21:46:36 -07:00
Wez Furlong 3e05ee667f procinfo: fix linux build 2021-12-31 21:31:28 -07:00
Wez Furlong 1ad4015f9c procinfo: reorg a bit; enable cwd probing on windows
Likely breaks the mac and windows builds
2021-12-31 21:28:03 -07:00
Wez Furlong e16a27dfb3 procinfo: fmt/refactor
Just moves some code around
2021-12-31 20:05:27 -07:00
Wez Furlong 6650879260 move platform logic about LocalProcessInfo into procinfo crate 2021-12-31 19:45:09 -07:00
Wez Furlong 416c700841 procinfo: start_time is now in unspecified units since boot 2021-12-31 19:39:37 -07:00
Wez Furlong 910b111efa move procinfo bits into own crate 2021-12-31 19:31:21 -07:00