@php-wasm/node 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/jspi/php_7_2.js CHANGED
@@ -8,7 +8,7 @@ import path from 'path';
8
8
 
9
9
  const dependencyFilename = path.join(__dirname, '7_2_34', 'php_7_2.wasm');
10
10
  export { dependencyFilename };
11
- export const dependenciesTotalSize = 17819046;
11
+ export const dependenciesTotalSize = 17819364;
12
12
  export function init(RuntimeName, PHPLoader) {
13
13
  // The rest of the code comes from the built php.js file and esm-suffix.js
14
14
  // include: shell.js
@@ -6950,6 +6950,44 @@ export function init(RuntimeName, PHPLoader) {
6950
6950
  // The files from the preload directory are preloaded using the
6951
6951
  // auto_prepend_file php.ini directive.
6952
6952
  FS.mkdir('/internal/shared/preload');
6953
+ // Create stdout and stderr devices. We can't just use Emscripten's
6954
+ // default stdout and stderr devices because they stop processing data
6955
+ // on the first null byte. However, when dealing with binary data,
6956
+ // null bytes are valid and common.
6957
+ FS.registerDevice(FS.makedev(64, 0), {
6958
+ open: () => {},
6959
+ close: () => {},
6960
+ read: () => 0,
6961
+ write: (stream, buffer, offset, length, pos) => {
6962
+ const chunk = buffer.subarray(offset, offset + length);
6963
+ PHPWASM.onStdout(chunk);
6964
+ return length;
6965
+ },
6966
+ });
6967
+ FS.mkdev('/internal/stdout', FS.makedev(64, 0));
6968
+ FS.registerDevice(FS.makedev(63, 0), {
6969
+ open: () => {},
6970
+ close: () => {},
6971
+ read: () => 0,
6972
+ write: (stream, buffer, offset, length, pos) => {
6973
+ const chunk = buffer.subarray(offset, offset + length);
6974
+ PHPWASM.onStderr(chunk);
6975
+ return length;
6976
+ },
6977
+ });
6978
+ FS.mkdev('/internal/stderr', FS.makedev(63, 0));
6979
+ FS.registerDevice(FS.makedev(62, 0), {
6980
+ open: () => {},
6981
+ close: () => {},
6982
+ read: () => 0,
6983
+ write: (stream, buffer, offset, length, pos) => {
6984
+ const chunk = buffer.subarray(offset, offset + length);
6985
+ PHPWASM.onHeaders(chunk);
6986
+ return length;
6987
+ },
6988
+ });
6989
+ FS.mkdev('/internal/headers', FS.makedev(62, 0));
6990
+ // Handle events.
6953
6991
  PHPWASM.EventEmitter = ENVIRONMENT_IS_NODE
6954
6992
  ? require('events').EventEmitter
6955
6993
  : class EventEmitter {
@@ -6990,9 +7028,71 @@ export function init(RuntimeName, PHPLoader) {
6990
7028
  }
6991
7029
  }
6992
7030
  };
7031
+ // Clean up the fd -> childProcess mapping when the fd is closed:
7032
+ const originalClose = FS.close;
7033
+ FS.close = function (stream) {
7034
+ originalClose(stream);
7035
+ delete PHPWASM.child_proc_by_fd[stream.fd];
7036
+ };
6993
7037
  PHPWASM.child_proc_by_fd = {};
6994
7038
  PHPWASM.child_proc_by_pid = {};
6995
7039
  PHPWASM.input_devices = {};
7040
+ const originalWrite = TTY.stream_ops.write;
7041
+ TTY.stream_ops.write = function (stream, ...rest) {
7042
+ const retval = originalWrite(stream, ...rest);
7043
+ // Implicit flush since PHP's fflush() doesn't seem to trigger the fsync event
7044
+ // @TODO: Fix this at the wasm level
7045
+ stream.tty.ops.fsync(stream.tty);
7046
+ return retval;
7047
+ };
7048
+ const originalPutChar = TTY.stream_ops.put_char;
7049
+ TTY.stream_ops.put_char = function (tty, val) {
7050
+ /**
7051
+ * Buffer newlines that Emscripten normally ignores.
7052
+ *
7053
+ * Emscripten doesn't do it by default because its default
7054
+ * print function is console.log that implicitly adds a newline. We are overwriting
7055
+ * it with an environment-specific function that outputs exaclty what it was given,
7056
+ * e.g. in Node.js it's process.stdout.write(). Therefore, we need to mak sure
7057
+ * all the newlines make it to the output buffer.
7058
+ */ if (val === 10) tty.output.push(val);
7059
+ return originalPutChar(tty, val);
7060
+ };
7061
+ },
7062
+ onHeaders: function (chunk) {
7063
+ if (Module['onHeaders']) {
7064
+ Module['onHeaders'](chunk);
7065
+ return;
7066
+ }
7067
+ console.log('headers', {
7068
+ chunk,
7069
+ });
7070
+ },
7071
+ onStdout: function (chunk) {
7072
+ if (Module['onStdout']) {
7073
+ Module['onStdout'](chunk);
7074
+ return;
7075
+ }
7076
+ if (ENVIRONMENT_IS_NODE) {
7077
+ process.stdout.write(chunk);
7078
+ } else {
7079
+ console.log('stdout', {
7080
+ chunk,
7081
+ });
7082
+ }
7083
+ },
7084
+ onStderr: function (chunk) {
7085
+ if (Module['onStderr']) {
7086
+ Module['onStderr'](chunk);
7087
+ return;
7088
+ }
7089
+ if (ENVIRONMENT_IS_NODE) {
7090
+ process.stderr.write(chunk);
7091
+ } else {
7092
+ console.warn('stderr', {
7093
+ chunk,
7094
+ });
7095
+ }
6996
7096
  },
6997
7097
  getAllWebSockets: function (sock) {
6998
7098
  const webSockets = new Set();
@@ -7174,7 +7274,7 @@ export function init(RuntimeName, PHPLoader) {
7174
7274
  argsArray.push(UTF8ToString(HEAPU32[charPointer >> 2]));
7175
7275
  }
7176
7276
  }
7177
- const cwdstr = cwdPtr ? UTF8ToString(cwdPtr) : null;
7277
+ const cwdstr = cwdPtr ? UTF8ToString(cwdPtr) : FS.cwd();
7178
7278
  let envObject = null;
7179
7279
  if (envLength) {
7180
7280
  envObject = {};
@@ -7247,6 +7347,15 @@ export function init(RuntimeName, PHPLoader) {
7247
7347
  PHPWASM.child_proc_by_fd[ProcInfo.stderrParentFd] = ProcInfo;
7248
7348
  PHPWASM.child_proc_by_pid[ProcInfo.pid] = ProcInfo;
7249
7349
  cp.on('exit', function (code) {
7350
+ for (const fd of [
7351
+ // The child process exited. Let's clean up its output streams:
7352
+ ProcInfo.stdoutChildFd,
7353
+ ProcInfo.stderrChildFd,
7354
+ ]) {
7355
+ if (FS.streams[fd] && !FS.isClosed(FS.streams[fd])) {
7356
+ FS.close(FS.streams[fd]);
7357
+ }
7358
+ }
7250
7359
  ProcInfo.exitCode = code;
7251
7360
  ProcInfo.exited = true;
7252
7361
  // Emit events for the wasm_poll_socket function.
@@ -7297,12 +7406,52 @@ export function init(RuntimeName, PHPLoader) {
7297
7406
  * listen to the 'exit' event.
7298
7407
  */ try {
7299
7408
  await new Promise((resolve, reject) => {
7300
- cp.on('spawn', resolve);
7301
- cp.on('error', reject);
7409
+ /**
7410
+ * There was no `await` between the `spawnProcess` call
7411
+ * and the `await` below so the process haven't had a chance
7412
+ * to run any of the exit-related callbacks yet.
7413
+ *
7414
+ * Good.
7415
+ *
7416
+ * Let's listen to all the lifecycle events and resolve
7417
+ * the promise when the process starts or immediately crashes.
7418
+ */ let resolved = false;
7419
+ cp.on('spawn', () => {
7420
+ if (resolved) return;
7421
+ resolved = true;
7422
+ resolve();
7423
+ });
7424
+ cp.on('error', (e) => {
7425
+ if (resolved) return;
7426
+ resolved = true;
7427
+ reject(e);
7428
+ });
7429
+ cp.on('exit', function (code) {
7430
+ if (resolved) return;
7431
+ resolved = true;
7432
+ if (code === 0) {
7433
+ resolve();
7434
+ } else {
7435
+ reject(
7436
+ new Error(`Process exited with code ${code}`)
7437
+ );
7438
+ }
7439
+ });
7440
+ /**
7441
+ * If the process haven't even started after 5 seconds, something
7442
+ * is wrong. Perhaps we're missing an event listener, or perhaps
7443
+ * the `spawnProcess` implementation failed to dispatch the relevant
7444
+ * event. Either way, let's crash to avoid blocking the proc_open()
7445
+ * call indefinitely.
7446
+ */ setTimeout(() => {
7447
+ if (resolved) return;
7448
+ resolved = true;
7449
+ reject(new Error('Process timed out'));
7450
+ }, 5e3);
7302
7451
  });
7303
7452
  } catch (e) {
7304
7453
  console.error(e);
7305
- wakeUp(1);
7454
+ wakeUp(ProcInfo.pid);
7306
7455
  return;
7307
7456
  }
7308
7457
  // Now we want to pass data from the STDIN source supplied by PHP
@@ -8008,14 +8157,7 @@ export function init(RuntimeName, PHPLoader) {
8008
8157
  const POLLNVAL = 32;
8009
8158
  return returnCallback((wakeUp) => {
8010
8159
  const polls = [];
8011
- if (socketd in PHPWASM.child_proc_by_fd) {
8012
- const procInfo = PHPWASM.child_proc_by_fd[socketd];
8013
- if (procInfo.exited) {
8014
- wakeUp(0);
8015
- return;
8016
- }
8017
- polls.push(PHPWASM.awaitEvent(procInfo.stdout, 'data'));
8018
- } else if (FS.isSocket(FS.getStream(socketd)?.node.mode)) {
8160
+ if (FS.isSocket(FS.getStream(socketd)?.node.mode)) {
8019
8161
  const sock = getSocketFromFD(socketd);
8020
8162
  if (!sock) {
8021
8163
  wakeUp(0);
@@ -8049,7 +8191,12 @@ export function init(RuntimeName, PHPLoader) {
8049
8191
  polls.push(PHPWASM.awaitConnection(ws));
8050
8192
  lookingFor.add('POLLOUT');
8051
8193
  }
8052
- if (events & POLLHUP) {
8194
+ if (
8195
+ events & POLLHUP ||
8196
+ events & POLLIN ||
8197
+ events & POLLOUT ||
8198
+ events & POLLERR
8199
+ ) {
8053
8200
  polls.push(PHPWASM.awaitClose(ws));
8054
8201
  lookingFor.add('POLLHUP');
8055
8202
  }
@@ -8058,6 +8205,13 @@ export function init(RuntimeName, PHPLoader) {
8058
8205
  lookingFor.add('POLLERR');
8059
8206
  }
8060
8207
  }
8208
+ } else if (socketd in PHPWASM.child_proc_by_fd) {
8209
+ const procInfo = PHPWASM.child_proc_by_fd[socketd];
8210
+ if (procInfo.exited) {
8211
+ wakeUp(0);
8212
+ return;
8213
+ }
8214
+ polls.push(PHPWASM.awaitEvent(procInfo.stdout, 'data'));
8061
8215
  } else {
8062
8216
  setTimeout(function () {
8063
8217
  wakeUp(1);
@@ -8343,13 +8497,6 @@ export function init(RuntimeName, PHPLoader) {
8343
8497
  (___wrap_select = Module['___wrap_select'] =
8344
8498
  wasmExports['__wrap_select'])(a0, a1, a2, a3, a4));
8345
8499
 
8346
- var _wasm_add_cli_arg = (Module['_wasm_add_cli_arg'] = (a0) =>
8347
- (_wasm_add_cli_arg = Module['_wasm_add_cli_arg'] =
8348
- wasmExports['wasm_add_cli_arg'])(a0));
8349
-
8350
- var _run_cli = (Module['_run_cli'] = () =>
8351
- (_run_cli = Module['_run_cli'] = wasmExports['run_cli'])());
8352
-
8353
8500
  var _wasm_set_sapi_name = (Module['_wasm_set_sapi_name'] = (a0) =>
8354
8501
  (_wasm_set_sapi_name = Module['_wasm_set_sapi_name'] =
8355
8502
  wasmExports['wasm_set_sapi_name'])(a0));
@@ -8358,6 +8505,13 @@ export function init(RuntimeName, PHPLoader) {
8358
8505
  (_wasm_set_phpini_path = Module['_wasm_set_phpini_path'] =
8359
8506
  wasmExports['wasm_set_phpini_path'])(a0));
8360
8507
 
8508
+ var _wasm_add_cli_arg = (Module['_wasm_add_cli_arg'] = (a0) =>
8509
+ (_wasm_add_cli_arg = Module['_wasm_add_cli_arg'] =
8510
+ wasmExports['wasm_add_cli_arg'])(a0));
8511
+
8512
+ var _run_cli = (Module['_run_cli'] = () =>
8513
+ (_run_cli = Module['_run_cli'] = wasmExports['run_cli'])());
8514
+
8361
8515
  var _wasm_add_SERVER_entry = (Module['_wasm_add_SERVER_entry'] = (a0, a1) =>
8362
8516
  (_wasm_add_SERVER_entry = Module['_wasm_add_SERVER_entry'] =
8363
8517
  wasmExports['wasm_add_SERVER_entry'])(a0, a1));
package/jspi/php_7_3.js CHANGED
@@ -8,7 +8,7 @@ import path from 'path';
8
8
 
9
9
  const dependencyFilename = path.join(__dirname, '7_3_33', 'php_7_3.wasm');
10
10
  export { dependencyFilename };
11
- export const dependenciesTotalSize = 17913346;
11
+ export const dependenciesTotalSize = 17913929;
12
12
  export function init(RuntimeName, PHPLoader) {
13
13
  // The rest of the code comes from the built php.js file and esm-suffix.js
14
14
  // include: shell.js
@@ -6950,6 +6950,44 @@ export function init(RuntimeName, PHPLoader) {
6950
6950
  // The files from the preload directory are preloaded using the
6951
6951
  // auto_prepend_file php.ini directive.
6952
6952
  FS.mkdir('/internal/shared/preload');
6953
+ // Create stdout and stderr devices. We can't just use Emscripten's
6954
+ // default stdout and stderr devices because they stop processing data
6955
+ // on the first null byte. However, when dealing with binary data,
6956
+ // null bytes are valid and common.
6957
+ FS.registerDevice(FS.makedev(64, 0), {
6958
+ open: () => {},
6959
+ close: () => {},
6960
+ read: () => 0,
6961
+ write: (stream, buffer, offset, length, pos) => {
6962
+ const chunk = buffer.subarray(offset, offset + length);
6963
+ PHPWASM.onStdout(chunk);
6964
+ return length;
6965
+ },
6966
+ });
6967
+ FS.mkdev('/internal/stdout', FS.makedev(64, 0));
6968
+ FS.registerDevice(FS.makedev(63, 0), {
6969
+ open: () => {},
6970
+ close: () => {},
6971
+ read: () => 0,
6972
+ write: (stream, buffer, offset, length, pos) => {
6973
+ const chunk = buffer.subarray(offset, offset + length);
6974
+ PHPWASM.onStderr(chunk);
6975
+ return length;
6976
+ },
6977
+ });
6978
+ FS.mkdev('/internal/stderr', FS.makedev(63, 0));
6979
+ FS.registerDevice(FS.makedev(62, 0), {
6980
+ open: () => {},
6981
+ close: () => {},
6982
+ read: () => 0,
6983
+ write: (stream, buffer, offset, length, pos) => {
6984
+ const chunk = buffer.subarray(offset, offset + length);
6985
+ PHPWASM.onHeaders(chunk);
6986
+ return length;
6987
+ },
6988
+ });
6989
+ FS.mkdev('/internal/headers', FS.makedev(62, 0));
6990
+ // Handle events.
6953
6991
  PHPWASM.EventEmitter = ENVIRONMENT_IS_NODE
6954
6992
  ? require('events').EventEmitter
6955
6993
  : class EventEmitter {
@@ -6990,9 +7028,71 @@ export function init(RuntimeName, PHPLoader) {
6990
7028
  }
6991
7029
  }
6992
7030
  };
7031
+ // Clean up the fd -> childProcess mapping when the fd is closed:
7032
+ const originalClose = FS.close;
7033
+ FS.close = function (stream) {
7034
+ originalClose(stream);
7035
+ delete PHPWASM.child_proc_by_fd[stream.fd];
7036
+ };
6993
7037
  PHPWASM.child_proc_by_fd = {};
6994
7038
  PHPWASM.child_proc_by_pid = {};
6995
7039
  PHPWASM.input_devices = {};
7040
+ const originalWrite = TTY.stream_ops.write;
7041
+ TTY.stream_ops.write = function (stream, ...rest) {
7042
+ const retval = originalWrite(stream, ...rest);
7043
+ // Implicit flush since PHP's fflush() doesn't seem to trigger the fsync event
7044
+ // @TODO: Fix this at the wasm level
7045
+ stream.tty.ops.fsync(stream.tty);
7046
+ return retval;
7047
+ };
7048
+ const originalPutChar = TTY.stream_ops.put_char;
7049
+ TTY.stream_ops.put_char = function (tty, val) {
7050
+ /**
7051
+ * Buffer newlines that Emscripten normally ignores.
7052
+ *
7053
+ * Emscripten doesn't do it by default because its default
7054
+ * print function is console.log that implicitly adds a newline. We are overwriting
7055
+ * it with an environment-specific function that outputs exaclty what it was given,
7056
+ * e.g. in Node.js it's process.stdout.write(). Therefore, we need to mak sure
7057
+ * all the newlines make it to the output buffer.
7058
+ */ if (val === 10) tty.output.push(val);
7059
+ return originalPutChar(tty, val);
7060
+ };
7061
+ },
7062
+ onHeaders: function (chunk) {
7063
+ if (Module['onHeaders']) {
7064
+ Module['onHeaders'](chunk);
7065
+ return;
7066
+ }
7067
+ console.log('headers', {
7068
+ chunk,
7069
+ });
7070
+ },
7071
+ onStdout: function (chunk) {
7072
+ if (Module['onStdout']) {
7073
+ Module['onStdout'](chunk);
7074
+ return;
7075
+ }
7076
+ if (ENVIRONMENT_IS_NODE) {
7077
+ process.stdout.write(chunk);
7078
+ } else {
7079
+ console.log('stdout', {
7080
+ chunk,
7081
+ });
7082
+ }
7083
+ },
7084
+ onStderr: function (chunk) {
7085
+ if (Module['onStderr']) {
7086
+ Module['onStderr'](chunk);
7087
+ return;
7088
+ }
7089
+ if (ENVIRONMENT_IS_NODE) {
7090
+ process.stderr.write(chunk);
7091
+ } else {
7092
+ console.warn('stderr', {
7093
+ chunk,
7094
+ });
7095
+ }
6996
7096
  },
6997
7097
  getAllWebSockets: function (sock) {
6998
7098
  const webSockets = new Set();
@@ -7174,7 +7274,7 @@ export function init(RuntimeName, PHPLoader) {
7174
7274
  argsArray.push(UTF8ToString(HEAPU32[charPointer >> 2]));
7175
7275
  }
7176
7276
  }
7177
- const cwdstr = cwdPtr ? UTF8ToString(cwdPtr) : null;
7277
+ const cwdstr = cwdPtr ? UTF8ToString(cwdPtr) : FS.cwd();
7178
7278
  let envObject = null;
7179
7279
  if (envLength) {
7180
7280
  envObject = {};
@@ -7247,6 +7347,15 @@ export function init(RuntimeName, PHPLoader) {
7247
7347
  PHPWASM.child_proc_by_fd[ProcInfo.stderrParentFd] = ProcInfo;
7248
7348
  PHPWASM.child_proc_by_pid[ProcInfo.pid] = ProcInfo;
7249
7349
  cp.on('exit', function (code) {
7350
+ for (const fd of [
7351
+ // The child process exited. Let's clean up its output streams:
7352
+ ProcInfo.stdoutChildFd,
7353
+ ProcInfo.stderrChildFd,
7354
+ ]) {
7355
+ if (FS.streams[fd] && !FS.isClosed(FS.streams[fd])) {
7356
+ FS.close(FS.streams[fd]);
7357
+ }
7358
+ }
7250
7359
  ProcInfo.exitCode = code;
7251
7360
  ProcInfo.exited = true;
7252
7361
  // Emit events for the wasm_poll_socket function.
@@ -7297,12 +7406,52 @@ export function init(RuntimeName, PHPLoader) {
7297
7406
  * listen to the 'exit' event.
7298
7407
  */ try {
7299
7408
  await new Promise((resolve, reject) => {
7300
- cp.on('spawn', resolve);
7301
- cp.on('error', reject);
7409
+ /**
7410
+ * There was no `await` between the `spawnProcess` call
7411
+ * and the `await` below so the process haven't had a chance
7412
+ * to run any of the exit-related callbacks yet.
7413
+ *
7414
+ * Good.
7415
+ *
7416
+ * Let's listen to all the lifecycle events and resolve
7417
+ * the promise when the process starts or immediately crashes.
7418
+ */ let resolved = false;
7419
+ cp.on('spawn', () => {
7420
+ if (resolved) return;
7421
+ resolved = true;
7422
+ resolve();
7423
+ });
7424
+ cp.on('error', (e) => {
7425
+ if (resolved) return;
7426
+ resolved = true;
7427
+ reject(e);
7428
+ });
7429
+ cp.on('exit', function (code) {
7430
+ if (resolved) return;
7431
+ resolved = true;
7432
+ if (code === 0) {
7433
+ resolve();
7434
+ } else {
7435
+ reject(
7436
+ new Error(`Process exited with code ${code}`)
7437
+ );
7438
+ }
7439
+ });
7440
+ /**
7441
+ * If the process haven't even started after 5 seconds, something
7442
+ * is wrong. Perhaps we're missing an event listener, or perhaps
7443
+ * the `spawnProcess` implementation failed to dispatch the relevant
7444
+ * event. Either way, let's crash to avoid blocking the proc_open()
7445
+ * call indefinitely.
7446
+ */ setTimeout(() => {
7447
+ if (resolved) return;
7448
+ resolved = true;
7449
+ reject(new Error('Process timed out'));
7450
+ }, 5e3);
7302
7451
  });
7303
7452
  } catch (e) {
7304
7453
  console.error(e);
7305
- wakeUp(1);
7454
+ wakeUp(ProcInfo.pid);
7306
7455
  return;
7307
7456
  }
7308
7457
  // Now we want to pass data from the STDIN source supplied by PHP
@@ -8008,14 +8157,7 @@ export function init(RuntimeName, PHPLoader) {
8008
8157
  const POLLNVAL = 32;
8009
8158
  return returnCallback((wakeUp) => {
8010
8159
  const polls = [];
8011
- if (socketd in PHPWASM.child_proc_by_fd) {
8012
- const procInfo = PHPWASM.child_proc_by_fd[socketd];
8013
- if (procInfo.exited) {
8014
- wakeUp(0);
8015
- return;
8016
- }
8017
- polls.push(PHPWASM.awaitEvent(procInfo.stdout, 'data'));
8018
- } else if (FS.isSocket(FS.getStream(socketd)?.node.mode)) {
8160
+ if (FS.isSocket(FS.getStream(socketd)?.node.mode)) {
8019
8161
  const sock = getSocketFromFD(socketd);
8020
8162
  if (!sock) {
8021
8163
  wakeUp(0);
@@ -8049,7 +8191,12 @@ export function init(RuntimeName, PHPLoader) {
8049
8191
  polls.push(PHPWASM.awaitConnection(ws));
8050
8192
  lookingFor.add('POLLOUT');
8051
8193
  }
8052
- if (events & POLLHUP) {
8194
+ if (
8195
+ events & POLLHUP ||
8196
+ events & POLLIN ||
8197
+ events & POLLOUT ||
8198
+ events & POLLERR
8199
+ ) {
8053
8200
  polls.push(PHPWASM.awaitClose(ws));
8054
8201
  lookingFor.add('POLLHUP');
8055
8202
  }
@@ -8058,6 +8205,13 @@ export function init(RuntimeName, PHPLoader) {
8058
8205
  lookingFor.add('POLLERR');
8059
8206
  }
8060
8207
  }
8208
+ } else if (socketd in PHPWASM.child_proc_by_fd) {
8209
+ const procInfo = PHPWASM.child_proc_by_fd[socketd];
8210
+ if (procInfo.exited) {
8211
+ wakeUp(0);
8212
+ return;
8213
+ }
8214
+ polls.push(PHPWASM.awaitEvent(procInfo.stdout, 'data'));
8061
8215
  } else {
8062
8216
  setTimeout(function () {
8063
8217
  wakeUp(1);
@@ -8343,13 +8497,6 @@ export function init(RuntimeName, PHPLoader) {
8343
8497
  (___wrap_select = Module['___wrap_select'] =
8344
8498
  wasmExports['__wrap_select'])(a0, a1, a2, a3, a4));
8345
8499
 
8346
- var _wasm_add_cli_arg = (Module['_wasm_add_cli_arg'] = (a0) =>
8347
- (_wasm_add_cli_arg = Module['_wasm_add_cli_arg'] =
8348
- wasmExports['wasm_add_cli_arg'])(a0));
8349
-
8350
- var _run_cli = (Module['_run_cli'] = () =>
8351
- (_run_cli = Module['_run_cli'] = wasmExports['run_cli'])());
8352
-
8353
8500
  var _wasm_set_sapi_name = (Module['_wasm_set_sapi_name'] = (a0) =>
8354
8501
  (_wasm_set_sapi_name = Module['_wasm_set_sapi_name'] =
8355
8502
  wasmExports['wasm_set_sapi_name'])(a0));
@@ -8358,6 +8505,13 @@ export function init(RuntimeName, PHPLoader) {
8358
8505
  (_wasm_set_phpini_path = Module['_wasm_set_phpini_path'] =
8359
8506
  wasmExports['wasm_set_phpini_path'])(a0));
8360
8507
 
8508
+ var _wasm_add_cli_arg = (Module['_wasm_add_cli_arg'] = (a0) =>
8509
+ (_wasm_add_cli_arg = Module['_wasm_add_cli_arg'] =
8510
+ wasmExports['wasm_add_cli_arg'])(a0));
8511
+
8512
+ var _run_cli = (Module['_run_cli'] = () =>
8513
+ (_run_cli = Module['_run_cli'] = wasmExports['run_cli'])());
8514
+
8361
8515
  var _wasm_add_SERVER_entry = (Module['_wasm_add_SERVER_entry'] = (a0, a1) =>
8362
8516
  (_wasm_add_SERVER_entry = Module['_wasm_add_SERVER_entry'] =
8363
8517
  wasmExports['wasm_add_SERVER_entry'])(a0, a1));