@@ -858,10 +858,9 @@ if (someConditionNotMet()) {
858858```
859859
860860The reason this is problematic is because writes to ` process.stdout ` in Node.js
861- are usually * non-blocking* and may occur over multiple ticks of the Node.js
862- event loop.
863- Calling ` process.exit() ` , however, forces the process to exit * before* those
864- additional writes to ` stdout ` can be performed.
861+ are sometimes * non-blocking* and may occur over multiple ticks of the Node.js
862+ event loop. Calling ` process.exit() ` , however, forces the process to exit
863+ * before* those additional writes to ` stdout ` can be performed.
865864
866865Rather than calling ` process.exit() ` directly, the code * should* set the
867866` process.exitCode ` and allow the process to exit naturally by avoiding
@@ -1429,15 +1428,20 @@ Android)
14291428The ` process.stderr ` property returns a [ Writable] [ ] stream equivalent to or
14301429associated with ` stderr ` (fd ` 2 ` ).
14311430
1432- ` process.stderr ` and ` process.stdout ` are unlike other streams in Node.js in
1433- that they cannot be closed (calling [ ` end() ` ] [ ] will throw an Error), they never
1434- emit the [ ` 'finish' ` ] [ ] event, and writes can block when output is redirected to
1435- a file (although disks are fast and operating systems normally employ write-back
1436- caching so it should be a very rare occurrence indeed.)
1431+ Note: ` process.stderr ` and ` process.stdout ` differ from other Node.js streams
1432+ in several ways:
1433+ 1 . They cannot be closed ([ ` end() ` ] [ ] will throw).
1434+ 2 . They never emit the [ ` 'finish' ` ] [ ] event.
1435+ 3 . Writes _ can_ block when output is redirected to a file.
1436+ - Note that disks are fast and operating systems normally employ write-back
1437+ caching so this is very uncommon.
1438+ 4 . Writes on UNIX __ will__ block by default if output is going to a TTY
1439+ (a terminal).
1440+ 5 . Windows functionality differs. Writes block except when output is going to a
1441+ TTY.
14371442
1438- Additionally, ` process.stderr ` and ` process.stdout ` are blocking when outputting
1439- to TTYs (terminals) on OS X as a workaround for the OS's very small, 1kb
1440- buffer size. This is to prevent interleaving between ` stdout ` and ` stderr ` .
1443+ To check if Node.js is being run in a TTY context, read the ` isTTY ` property
1444+ on ` process.stderr ` , ` process.stdout ` , or ` process.stdin ` :
14411445
14421446## process.stdin
14431447
@@ -1482,11 +1486,17 @@ console.log = (msg) => {
14821486};
14831487```
14841488
1485- ` process.stderr ` and ` process.stdout ` are unlike other streams in Node.js in
1486- that they cannot be closed (calling [ ` end() ` ] [ ] will throw an Error), they never
1487- emit the [ ` 'finish' ` ] [ ] event and that writes can block when output is
1488- redirected to a file (although disks are fast and operating systems normally
1489- employ write-back caching so it should be a very rare occurrence indeed.)
1489+ Note: ` process.stderr ` and ` process.stdout ` differ from other Node.js streams
1490+ in several ways:
1491+ 1 . They cannot be closed ([ ` end() ` ] [ ] will throw).
1492+ 2 . They never emit the [ ` 'finish' ` ] [ ] event.
1493+ 3 . Writes _ can_ block when output is redirected to a file.
1494+ - Note that disks are fast and operating systems normally employ write-back
1495+ caching so this is very uncommon.
1496+ 4 . Writes on UNIX __ will__ block by default if output is going to a TTY
1497+ (a terminal).
1498+ 5 . Windows functionality differs. Writes block except when output is going to a
1499+ TTY.
14901500
14911501To check if Node.js is being run in a TTY context, read the ` isTTY ` property
14921502on ` process.stderr ` , ` process.stdout ` , or ` process.stdin ` :
0 commit comments