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

src: fix the false isatty() issue on IBMi #30829

Closed
wants to merge 1 commit into from
Closed

src: fix the false isatty() issue on IBMi #30829

wants to merge 1 commit into from

Conversation

dmabupt
Copy link
Contributor

@dmabupt dmabupt commented Dec 7, 2019

IBMi PASE always says it is a tty terminal.
For ssh terminals it is true, but for terminals like TN5250 it is not.
Need to identify whether it is actually in a TTY or not.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Dec 7, 2019
@richardlau
Copy link
Member

Presumably this is related to https://www.ibm.com/support/pages/nodejs-failure-pase-error-560-assertion? (And, if so, setting the PASE_STDIO_ISATTY environment variable in code is not an option?)

@dmabupt
Copy link
Contributor Author

dmabupt commented Dec 7, 2019

Presumably this is related to https://www.ibm.com/support/pages/nodejs-failure-pase-error-560-assertion? (And, if so, setting the PASE_STDIO_ISATTY environment variable in code is not an option?)

Yes, that is the issue.
We can work around by setting PASE_STDIO_ISATTY=N but I think maybe it is better to directly get the result.

@cjihrig
Copy link
Contributor

cjihrig commented Dec 7, 2019

Somewhat related question: is it worth teaching uv_guess_handle() about this?

src/node.cc Outdated Show resolved Hide resolved
@richardlau
Copy link
Member

There are some linter failures:

https://travis-ci.com/nodejs/node/jobs/264279822#L301-L308

Running C++ linter...
src/node.cc:113:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/node.cc:562:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/node.cc:564:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
src/node.cc:565:  Use nullptr instead of NULL  [readability/null_usage] [2]
src/node.cc:566:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
Done processing src/node.cc
Total errors found: 5

@nodejs-github-bot
Copy link
Collaborator

@dmabupt
Copy link
Contributor Author

dmabupt commented Dec 7, 2019

uv_guess_handle()

Hello @cjihrig , Do you know any API or test case using uv_guess_handle()? I found test/parallel/test-ttywrap-invalid-fd.js but it seems to be an internal case that I can not directly run?

@richardlau richardlau added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 7, 2019
@richardlau
Copy link
Member

uv_guess_handle()

Hello @cjihrig , Do you know any API or test case using uv_guess_handle()? I found test/parallel/test-ttywrap-invalid-fd.js but it seems to be an internal case that I can not directly run?

@dmabupt If you're not running via the test runner (i.e. tools/test.py parallel/test-ttywrap-invalid-fd) you need to append the flags from the // Flags: comment (i.e. node --expose-internals test/parallel/test-ttywrap-invalid-fd.js).

libuv has its own tests that use uv_guess_handle(). See build instructions and running tests for how to build libuv and run tests (I assume you already know this since you've already contributed to libuv).

@cjihrig
Copy link
Contributor

cjihrig commented Dec 7, 2019

@dmabupt the documentation for uv_guess_handle() states:

For isatty(3) equivalent functionality use this function and test for UV_TTY.

So I just thought that while you're adding this functionality to Node, it would probably be worthwhile to add it to libuv as well. In fact, uv_guess_handle() could then be used to clean this code up a little bit (one less #ifdef).

@dmabupt
Copy link
Contributor Author

dmabupt commented Dec 8, 2019

@dmabupt the documentation for uv_guess_handle() states:

For isatty(3) equivalent functionality use this function and test for UV_TTY.

So I just thought that while you're adding this functionality to Node, it would probably be worthwhile to add it to libuv as well. In fact, uv_guess_handle() could then be used to clean this code up a little bit (one less #ifdef).

Thanks for the information. I have submiited a PR for that.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
Use ioctl() instead to identify whether it's actually a TTY.
@dmabupt
Copy link
Contributor Author

dmabupt commented Dec 9, 2019

I have updated the code to --

    if (ioctl(fd, TXISATTY + 0x81, nullptr) == -1 && errno == ENOTTY)
      continue;

to specifically detect the ENOTTY environment.

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

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

LGTM

BridgeAR pushed a commit that referenced this pull request Dec 9, 2019
On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
Use ioctl() instead to identify whether it's actually a TTY.

PR-URL: #30829
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@BridgeAR
Copy link
Member

BridgeAR commented Dec 9, 2019

Landed in 68874a6 🎉

@BridgeAR BridgeAR closed this Dec 9, 2019
@dmabupt dmabupt deleted the ibmi_isatty branch December 10, 2019 05:35
targos pushed a commit that referenced this pull request Dec 10, 2019
On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
Use ioctl() instead to identify whether it's actually a TTY.

PR-URL: #30829
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 13, 2019
targos pushed a commit that referenced this pull request Jan 14, 2020
On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
Use ioctl() instead to identify whether it's actually a TTY.

PR-URL: #30829
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
cjihrig added a commit to cjihrig/node that referenced this pull request Jan 15, 2020
This commit reverts nodejs#30829
and uses uv_guess_handle() instead of isatty(). The IBMi
changes are no longer required, as of libuv 1.34.1.

PR-URL: nodejs#31333
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
MylesBorins pushed a commit that referenced this pull request Jan 16, 2020
This commit reverts #30829
and uses uv_guess_handle() instead of isatty(). The IBMi
changes are no longer required, as of libuv 1.34.1.

PR-URL: #31333
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
On IBMi PASE isatty() always returns true for stdin, stdout and stderr.
Use ioctl() instead to identify whether it's actually a TTY.

PR-URL: #30829
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
codebytere pushed a commit that referenced this pull request Mar 14, 2020
This commit reverts #30829
and uses uv_guess_handle() instead of isatty(). The IBMi
changes are no longer required, as of libuv 1.34.1.

PR-URL: #31333
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
codebytere pushed a commit that referenced this pull request Mar 17, 2020
This commit reverts #30829
and uses uv_guess_handle() instead of isatty(). The IBMi
changes are no longer required, as of libuv 1.34.1.

PR-URL: #31333
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: David Carlier <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants