Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to fork from vfork #217

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

timmattison
Copy link
Contributor

Motivation

  • The compilation phase on MacOS treats usage of vfork as an error instead of a warning. This changes vfork -> fork to allow compilation on MacOS.

Modifications

Change summary

Just one change of vfork -> fork

Testing

No CI for this but I needed to make this change in order to build the project on Mac OS. fork does work slightly differently than vfork though so I may add some more comments later once I've verified that it works as expected.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Avoids deprecation warnings and works on MacOS
@HarshGandhi-AWS HarshGandhi-AWS self-assigned this Jun 14, 2022
@monelgordillo
Copy link

During "cmake --build . --target aws-iot-device-client" I get this:

aws-iot-device-client/source/jobs/JobEngine.cpp:276:15: error: 'vfork' is deprecated: Use posix_spawn or fork [-Werror,-Wdeprecated-declarations]
    int pid = vfork();

@@ -270,7 +270,7 @@ int JobEngine::exec_cmd(string operation, PlainJobDocument::JobAction action)

int execResult;
int returnCode;
int pid = vfork();
int pid = fork();
Copy link
Contributor

Choose a reason for hiding this comment

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

Child process created byvfork() suspends execution of parent process until child process completes its execution wereas, both parent and the child process created usingfork() start their execution from next statement after fork() and both processes get executed simultaneously.

This might result in executing multiple job executions simultaneously.

Device Client anyways does not work on Mac OS so I would not encourage making this change until we make the software MacOS compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The child and parent process do different things. The parent process waits for the child process to finish already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants