@@ -880,10 +880,9 @@ if (someConditionNotMet()) {
880880```
881881
882882The reason this is problematic is because writes to ` process.stdout ` in Node.js
883- are usually * non-blocking* and may occur over multiple ticks of the Node.js
884- event loop.
885- Calling ` process.exit() ` , however, forces the process to exit * before* those
886- additional writes to ` stdout ` can be performed.
883+ are sometimes * non-blocking* and may occur over multiple ticks of the Node.js
884+ event loop. Calling ` process.exit() ` , however, forces the process to exit
885+ * before* those additional writes to ` stdout ` can be performed.
887886
888887Rather than calling ` process.exit() ` directly, the code * should* set the
889888` process.exitCode ` and allow the process to exit naturally by avoiding
@@ -1451,15 +1450,20 @@ Android)
14511450The ` process.stderr ` property returns a [ Writable] [ ] stream equivalent to or
14521451associated with ` stderr ` (fd ` 2 ` ).
14531452
1454- ` process.stderr ` and ` process.stdout ` are unlike other streams in Node.js in
1455- that they cannot be closed (calling [ ` end() ` ] [ ] will throw an Error), they never
1456- emit the [ ` 'finish' ` ] [ ] event, and writes can block when output is redirected to
1457- a file (although disks are fast and operating systems normally employ write-back
1458- caching so it should be a very rare occurrence indeed.)
1453+ Note: ` process.stderr ` and ` process.stdout ` differ from other Node.js streams
1454+ in several ways:
1455+ 1 . They cannot be closed ([ ` end() ` ] [ ] will throw).
1456+ 2 . They never emit the [ ` 'finish' ` ] [ ] event.
1457+ 3 . Writes _ can_ block when output is redirected to a file.
1458+ - Note that disks are fast and operating systems normally employ write-back
1459+ caching so this is very uncommon.
1460+ 4 . Writes on UNIX __ will__ block by default if output is going to a TTY
1461+ (a terminal).
1462+ 5 . Windows functionality differs. Writes block except when output is going to a
1463+ TTY.
14591464
1460- Additionally, ` process.stderr ` and ` process.stdout ` are blocking when outputting
1461- to TTYs (terminals) on OS X as a workaround for the OS's very small, 1kb
1462- buffer size. This is to prevent interleaving between ` stdout ` and ` stderr ` .
1465+ To check if Node.js is being run in a TTY context, read the ` isTTY ` property
1466+ on ` process.stderr ` , ` process.stdout ` , or ` process.stdin ` :
14631467
14641468## process.stdin
14651469
@@ -1504,11 +1508,17 @@ console.log = (msg) => {
15041508};
15051509```
15061510
1507- ` process.stderr ` and ` process.stdout ` are unlike other streams in Node.js in
1508- that they cannot be closed (calling [ ` end() ` ] [ ] will throw an Error), they never
1509- emit the [ ` 'finish' ` ] [ ] event and that writes can block when output is
1510- redirected to a file (although disks are fast and operating systems normally
1511- employ write-back caching so it should be a very rare occurrence indeed.)
1511+ Note: ` process.stderr ` and ` process.stdout ` differ from other Node.js streams
1512+ in several ways:
1513+ 1 . They cannot be closed ([ ` end() ` ] [ ] will throw).
1514+ 2 . They never emit the [ ` 'finish' ` ] [ ] event.
1515+ 3 . Writes _ can_ block when output is redirected to a file.
1516+ - Note that disks are fast and operating systems normally employ write-back
1517+ caching so this is very uncommon.
1518+ 4 . Writes on UNIX __ will__ block by default if output is going to a TTY
1519+ (a terminal).
1520+ 5 . Windows functionality differs. Writes block except when output is going to a
1521+ TTY.
15121522
15131523To check if Node.js is being run in a TTY context, read the ` isTTY ` property
15141524on ` process.stderr ` , ` process.stdout ` , or ` process.stdin ` :
0 commit comments