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

change std::system to popen #156

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

change std::system to popen #156

wants to merge 3 commits into from

Conversation

gouarin
Copy link
Contributor

@gouarin gouarin commented Jul 23, 2017

This PR changes the method to execute a shell command in order to control the output stream.

This solves the issue #154

Copy link
Owner

@vgvassilev vgvassilev left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Could you add a test for it?

std::string command = trimmed.str() + " 2>&1";
FILE *shell_result = popen(command.c_str(), "r");
if (shell_result)
{
Copy link
Owner

Choose a reason for hiding this comment

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

Could you move the brace to the previous line.

{
char buff[512];
ret = 0;
while(fgets(buff, sizeof(buff), shell_result)!=NULL){
Copy link
Owner

Choose a reason for hiding this comment

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

It is more common in cling's codebase to use ! upfront and rely on the implicit bool conversion.

I'd add a space after the brace.

@gouarin
Copy link
Contributor Author

gouarin commented Jul 24, 2017

@vgvassilev, could you tell me how to build the test suite ? I use clone.sh script to build cling. I add the flag -DCLING_INCLUDE_TESTS but it doesn't work.

char buff[512];
ret = 0;
while(fgets(buff, sizeof(buff), shell_result)!=NULL){
bool flag = fgets(buff, sizeof(buff), shell_result) == NULL;
Copy link
Owner

Choose a reason for hiding this comment

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

What about while(!fgets(buff, sizeof(buff), shell_result))?

@vgvassilev
Copy link
Owner

You should be able to do make help. I believe there is a target make check-cling or something like that.

@gouarin
Copy link
Contributor Author

gouarin commented Jul 24, 2017

@vgvassilev, do I add the test in the Prompt directory ?

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.

2 participants