Skip to content

fix how we find parent process - #472

Merged
cfbao merged 1 commit into
mainfrom
fix-parent-proc
Jul 26, 2024
Merged

fix how we find parent process#472
cfbao merged 1 commit into
mainfrom
fix-parent-proc

Conversation

@cfbao

@cfbao cfbao commented Jul 26, 2024

Copy link
Copy Markdown
Contributor

Why

Turns out BusyBox only implements a small portion of the POSIX spec for its ps, so our code that gets the parent process (and hence bmx print) never worked on Alpine...
(I guess no one ever used bmx print on alpine...)

Switch to use native API call, which is actually easier.

Ticket

https://desire2learn.atlassian.net/browse/VUL-403

Comment on lines -48 to +50
$releaseUrl = gh release create "$env:RELEASE_TAG" --repo Brightspace/bmx --draft --prerelease --generate-notes --title "Release $env:RELEASE_TAG"
$releaseUrl = gh release create "$env:RELEASE_TAG" --repo Brightspace/bmx --draft --prerelease --generate-notes --title "Release $env:RELEASE_TAG" --target $env:GITHUB_SHA
} else {
$releaseUrl = gh release create "$env:RELEASE_TAG" --repo Brightspace/bmx --draft --generate-notes --title "Release $env:RELEASE_TAG"
$releaseUrl = gh release create "$env:RELEASE_TAG" --repo Brightspace/bmx --draft --generate-notes --title "Release $env:RELEASE_TAG" --target $env:GITHUB_SHA

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated fix - our release job only worked on the main branch.

Comment on lines -13 to +11
internal partial class WindowsParentProcess {
internal partial class ParentProcess {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidated both the previous Windows and Unix classes under the same one now.
The high level method GetParentProcessName has identical logic.

Comment on lines +19 to +21
if( parentPid == -1 ) {
return null;
}

@cfbao cfbao Jul 26, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new.
GetWindowsParentProcessId returns -1 on error. We should check that, instead of passing it to GetProcessById, which will throw.
We have default fallback behaviour on each OS, so throwing doesn't make sense.

Comment on lines -15 to -16
[LibraryImport( "ntdll.dll", EntryPoint = "NtQueryInformationProcess" )]
internal static partial int NtQueryInformationProcess(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved below, as per our convention to put public/high-level methods first, and private/low-level/helper methods after.
Also changed it to private, as it's not used elsewhere.

@cfbao
cfbao marked this pull request as ready for review July 26, 2024 13:32
@cfbao
cfbao requested a review from a team as a code owner July 26, 2024 13:32
@cfbao
cfbao merged commit d8e59c1 into main Jul 26, 2024
@cfbao
cfbao deleted the fix-parent-proc branch July 26, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants