Skip to content

Conversation

FrogTheFrog
Copy link
Contributor

Description

This solves a bug introduced accidentally by #600.

When starting an attached command/process on linux, you are welcomed by this error:
image

terminate called after throwing an instance of 'boost::process::process_error'
  what():  killpg(2) failed in terminate: Invalid argument
Aborted (core dumped)

It seems that for whatever reason, if your child is going to be in a process group, it has to be in it from the start boostorg/process#164 in order for the group methods to work properly.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

Branch Updates

LizardByte requires that branches be up-to-date before merging. This means that after any PR is merged, this branch
must be updated before it can be merged. You must also
Allow edits from maintainers.

  • I want maintainers to keep my branch updated

@CLAassistant
Copy link

CLAassistant commented Jan 14, 2023

CLA assistant check
All committers have signed the CLA.

src/process.cpp Outdated
@@ -150,12 +150,14 @@ int proc_t::execute(int app_id) {
find_working_directory(cmd, _env) :
boost::filesystem::path(proc.working_dir);
BOOST_LOG(info) << "Spawning ["sv << cmd << "] in ["sv << working_dir << ']';
auto child = platf::run_unprivileged(cmd, working_dir, _env, _pipe.get(), ec);
bp::group child_group;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: I don't really like this myself that there is a need to pass a temporary group, but I don't know how to do it optionally without creating 2 function versions. The boost::child constructor is just meh...

@FrogTheFrog
Copy link
Contributor Author

Got an advice that temporary group could have had some strange behavior on Windows, so duplicating code instead :/

@FrogTheFrog
Copy link
Contributor Author

@cgutman Sorry to tag you like this, but could I ask for a review from you? Since I know you're more knowledgeable about boost::process stuff?

@FrogTheFrog
Copy link
Contributor Author

It seems that ctor does not accept PID with other arguments. Since it was working this way on Windows before and it's only broken on linux, the child can be added to the group manually via method.

@cgutman cgutman merged commit c81aa99 into LizardByte:nightly Jan 19, 2023
@FrogTheFrog FrogTheFrog deleted the nightly branch January 19, 2023 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants