Adar Dembo has posted comments on this change.

Change subject: Add option to set CWD to Subprocess
......................................................................


Patch Set 2:

(6 comments)

http://gerrit.cloudera.org:8080/#/c/7176/2/src/kudu/util/subprocess-test.cc
File src/kudu/util/subprocess-test.cc:

Line 147:   p.SetCurrentDir(DirName(kTestFilePath));
I imagine the cwd of a gtest isn't the same as GetTestPath(""), but just in 
case it is (and to make it clear in the test), consider creating a subdirectory 
within GetTestPath(""), putting foo in there, and configure the subprocess to 
change into that subdir.


PS2, Line 150:   FILE* in = fdopen(p.from_child_stdout_fd(), "r");
             :   PCHECK(in);
             :   char buf[1024];
             :   ASSERT_EQ(buf, fgets(buf, sizeof(buf), in));
             :   ASSERT_STREQ("foo\n", &buf[0]);
             :   ASSERT_OK(p.Wait());
Does the output of ls actually matter? How about just using p.GetExitStatus() 
to ensure that the exit status was zero? It should be non-zero if 'foo' didn't 
exist, right?


http://gerrit.cloudera.org:8080/#/c/7176/2/src/kudu/util/subprocess.cc
File src/kudu/util/subprocess.cc:

Line 426:         PLOG(ERROR) << "Unable to set subprocess current directory to 
" << cwd_;
> rc here is -1, and PLOG() will output information on errno.
I think PCHECK() would be net fewest lines of code. We already use it on L409 
for close().


Line 693: void Subprocess::SetEnvVars(std::map<string, string> env) {
Nit: could you drop the std:: prefix from map too?


Line 697: void Subprocess::SetCurrentDir(string cwd) {
We should check that the subprocess hasn't yet started. Same goes for 
SetEnvVars() (not your fault).


http://gerrit.cloudera.org:8080/#/c/7176/2/src/kudu/util/subprocess.h
File src/kudu/util/subprocess.h:

PS2, Line 80: SetCurrentDir
> Another approach would be specifying the starting directory as an additiona
Agreed that setting it at construction time would be nice; then cwd_ could be 
const and there'd be no need to verify that the subprocess hasn't already 
started.

But, the constructor already has some optional arguments. Seems like a 
subprocess builder would be ideal, which could incorporate DisableStd*, 
ShareParentStd*, and SetEnvVars too.


-- 
To view, visit http://gerrit.cloudera.org:8080/7176
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I73dc4983b0074312623790ce026e6ad88439df89
Gerrit-PatchSet: 2
Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-Owner: Dan Burkert <[email protected]>
Gerrit-Reviewer: Adar Dembo <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-HasComments: Yes

Reply via email to