2016-07-19 05:50:27 +02:00
|
|
|
'use strict';
|
2017-03-24 17:46:44 +01:00
|
|
|
|
|
|
|
const common = require('../common');
|
2016-07-19 05:50:27 +02:00
|
|
|
|
|
|
|
const { TTY, isTTY } = process.binding('tty_wrap');
|
|
|
|
const strictEqual = require('assert').strictEqual;
|
|
|
|
|
|
|
|
strictEqual(isTTY(0), true, 'fd 0 is not a TTY');
|
|
|
|
|
|
|
|
const handle = new TTY(0);
|
|
|
|
handle.readStart();
|
2017-03-24 17:46:44 +01:00
|
|
|
handle.onread = common.noop;
|
2016-07-19 05:50:27 +02:00
|
|
|
|
|
|
|
function isHandleActive(handle) {
|
|
|
|
return process._getActiveHandles().some((active) => active === handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
strictEqual(isHandleActive(handle), true, 'TTY handle not initially active');
|
|
|
|
|
|
|
|
handle.unref();
|
|
|
|
|
|
|
|
strictEqual(isHandleActive(handle), false, 'TTY handle active after unref()');
|
|
|
|
|
|
|
|
handle.ref();
|
|
|
|
|
|
|
|
strictEqual(isHandleActive(handle), true, 'TTY handle inactive after ref()');
|
|
|
|
|
|
|
|
handle.unref();
|