Skip to content

Use strongly typed Pid and Option<Pid> types#10844

Merged
mqudsi merged 5 commits intofish-shell:masterfrom
mqudsi:pid-type
Nov 14, 2024
Merged

Use strongly typed Pid and Option<Pid> types#10844
mqudsi merged 5 commits intofish-shell:masterfrom
mqudsi:pid-type

Conversation

@mqudsi
Copy link
Copy Markdown
Contributor

@mqudsi mqudsi commented Nov 11, 2024

There's a separate AtomicPid type because relying on not storing zero or negative values into a NonZeroI32 was not working. This found a number of bugs or unhandled cases in the codebase.

One thing I want to make sure of is that it is indeed an error to use bg %0 or jobs -q 0 in the sense that they can never match a job?

Closes #10832

@mqudsi
Copy link
Copy Markdown
Contributor Author

mqudsi commented Nov 11, 2024

Is the macOS tmux failure related? I'd say no but it failed twice.

Nope, it's just macOS CI being macOS CI.

@mqudsi mqudsi added this to the fish 4.0 milestone Nov 12, 2024
The previous approach of "treat this field as an `Option<NonZeroU32>` and
remember to check `p.has_pid()` before accessing it" was a mix of C++ and rust
conventions and led to some bugs or incorrect behaviors.

* `jobs -p` would previously print both the (correct) external pid and the
  (incorrect) internal value of `0` if a backgrounded command contained a
  fish function (e.g. `function foo; end; cat | foo &; jobs`)
* Updating/calculating job cpu time and usage was incorrectly including all of
  fish's cpu usage/time for each function/builtin member of the job pipeline.

Closes fish-shell#10832
Statically assert that the interior value is both positive and non-zero.
This caught an incorrect description for process/job exit handlers for ANY_PID
(now removed) which has been replaced with a message stating the handler is for
any process exit event.
@mqudsi mqudsi merged commit 4061ef7 into fish-shell:master Nov 14, 2024
@zanchey zanchey added the rust label Nov 17, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Nov 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Job id expansion fails for mixed process/function pipelines

2 participants