pty.js icon indicating copy to clipboard operation
pty.js copied to clipboard

Fixed install warning

Open coderaiser opened this issue 11 years ago • 10 comments
trafficstars

./src/unix/pty.cc: In function ‘v8::Handle<v8::Value> PtyFork(const v8::Arguments&)’:
../src/unix/pty.cc:185:34: warning: ignoring return value of ‘int chdir(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
       if (strlen(cwd)) chdir(cwd);

coderaiser avatar Sep 12 '14 14:09 coderaiser

Isn't your if condition backward?

JamesMGreene avatar Jun 20 '15 15:06 JamesMGreene

ignoring return value of ‘int chdir(const char*)’, declared with attribute warn_unused_result

Looks like result of chdir should not be ignored and this if condition checks it.

coderaiser avatar Jun 20 '15 15:06 coderaiser

Oh, I suppose chdir returns 1 for errors rather than false, huh? If so, my mistake.

JamesMGreene avatar Jun 20 '15 16:06 JamesMGreene

On success, zero is returned. On error, -1 is returned. chdir(2).

coderaiser avatar Jun 20 '15 17:06 coderaiser

Gotcha, sorry for the confusion!

JamesMGreene avatar Jun 20 '15 17:06 JamesMGreene

That's OK, I don't think that it would be merged sometime anyway, I created this pull request nearly year ago :). Nobody looks after this repository. I even tried to find something similar to pty.js and tty.js but under active development. Nothing unfortunately.

coderaiser avatar Jun 20 '15 18:06 coderaiser

That's actually why I commented: I forked the repo and was going to start merging pull requests into my own version of it, so I wanted to verify the correctness of this change. :smile:

JamesMGreene avatar Jun 21 '15 12:06 JamesMGreene

I see, I think it's great idea. I thin this commit good thing to merge, because of install warning. Anyway it is better to change perror("chdir failed"); -> perror("chdir " + cwd + " failed");

coderaiser avatar Jun 21 '15 12:06 coderaiser

Noted, thanks!

JamesMGreene avatar Jun 21 '15 13:06 JamesMGreene

@coderaiser: If you're interested, you can check out my fork now:

  • https://github.com/JamesMGreene/node-partty
  • https://www.npmjs.com/package/partty

JamesMGreene avatar Jun 22 '15 09:06 JamesMGreene