Skip to content

Modify the handling of exit code in lpython.cpp #1352

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

Merged
merged 3 commits into from
Dec 31, 2022

Conversation

Thirumalai-Shaktivel
Copy link
Collaborator

Closes: #1316

@Thirumalai-Shaktivel Thirumalai-Shaktivel added the ready for review PRs that are ready for review label Dec 10, 2022
@@ -1657,6 +1657,8 @@ int main(int argc, char *argv[])
if (err != 0) {
if (0 < err && err < 256) {
return err;
} else if (err % 256 == 0) {
return err / 256;
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this do exactly? Let's document it in a comment.

Copy link
Collaborator Author

@Thirumalai-Shaktivel Thirumalai-Shaktivel Dec 13, 2022

Choose a reason for hiding this comment

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

return 1;
// https://stackoverflow.com/a/27117435/15913193
// https://linux.die.net/man/3/system
return WEXITSTATUS(err);
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not compile on Windows:

D:\a\lpython\lpython\lpython-0.8.0-14-gb2d00ab00\src\bin\lpython.cpp(1663): error C3861: 'WEXITSTATUS': identifier not found

Copy link
Collaborator Author

@Thirumalai-Shaktivel Thirumalai-Shaktivel Dec 28, 2022

Choose a reason for hiding this comment

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

I'm Sorry, @certik. I forgot the suggestions you gave on this.
Would this: cfeb641 be a valid fix

@@ -1658,7 +1658,9 @@ int main(int argc, char *argv[])
if (0 < err && err < 256) {
return err;
} else {
return 1;
// https://stackoverflow.com/a/27117435/15913193
// https://linux.die.net/man/3/system
Copy link
Contributor

Choose a reason for hiding this comment

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

Move these two links into the utils.cpp file to document get_exit_status?

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

I think this looks good, I just left some minor comments.

@@ -12,6 +12,8 @@ std::string get_runtime_library_header_dir();
bool is_directory(std::string path);
bool path_exists(std::string path);

int32_t get_exit_status(int32_t err);
Copy link
Contributor

Choose a reason for hiding this comment

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

Document here what the function does, you can put the links above here as well.

@Thirumalai-Shaktivel
Copy link
Collaborator Author

Thanks for the approval. Let's merge this.

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

Successfully merging this pull request may close these issues.

Modify the handling of exit to throw the correct code
2 participants