Skip to content

probe (temporary, will be closed): argument zero with '/' on Windows - #4

Closed
Sunrisepeak wants to merge 37 commits into
mainfrom
probe-windows-argv0
Closed

Sunrisepeak wants to merge 37 commits into
mainfrom
probe-windows-argv0

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Owner

Temporary measurement for #1; closed after one run.

mcpp.toml states the rows the openkal platform and the DJGPP platform serve
beyond mcpp's built-in table (i686 Linux, the i386 openkal image, UEFI, DOS),
the musl define for the FreeBSD and macOS rows, the Emscripten flags, and the
System V shims for DJGPP.  mcpp/cmd.rc is cmd.rc without its winres.h include,
so the version resource also compiles for the UEFI row.

Sources: lselfpath.c skips sysctl and _NSGetExecutablePath under musl;
glibcmd.h, lreadline.c, llinenoise.c and lsysport.c build where SIGTSTP,
<sys/select.h>, EWOULDBLOCK and clock_settime are absent (DJGPP).  Every other
build is unchanged.

README: the mcpp section lists each target with its build command.
mcpp.toml states the rows platform packages serve as one [target] table and
keeps its comments short. The README's table opens from one sentence.

.github/workflows/mcpp.yml builds every target in the table. Linux x86_64 and
arm64, macOS and Windows build and run on the machine itself; the others are
built on Linux and run on Windows arm64, macOS x86_64, FreeBSD (x86_64 and
aarch64), the Android emulator, DOSBox and UEFI firmware, or are only built.
Each run of .github/mcpp/test.bat is compared with .github/mcpp/expected.txt.
…s under node.

build.mcpp states the Emscripten link: node's file system by default, and with
the web profile an in-memory file system and a module that mcpp/web.html
starts.  mcpp's dist-web plugin packs that page and the program as a web
directory (mcpp pack cmd.exe --profile web --target wasm32-emscripten
--pkg-format web).

llinenoise.c: Emscripten accepts tcsetattr() but has no raw mode, so Enter
arrived as '\n' inside the edited line and no typed command ever ran; lines
are now read whole there, as on an unsupported terminal.

The workflow types lines at the prompt of the Linux and node builds, runs the
web directory in Chrome and, on main, publishes it to GitHub Pages.  The
README states what each target was verified to do.
The page shows why it cannot start instead of failing silently: opened
from disk, a browser refuses to fetch the .wasm, and the page says how to
serve the directory.  Standard input reads end of file, so set /p and
pause no longer open a browser dialog.
…arm64.

The Windows arm64 run had not finished after 40 minutes; the probe starts
the program with /c ver and standard input closed first.
The interpreter starts there, and the script stops without output.
…rm64.

CALL saves its return point with ftell() and EXIT /B restores it with
fseek().  In text mode the Windows C runtime miscounts ftell() on a file
whose lines end in LF alone, so EXIT /B returned to the CALL line and the
script never ended.  The line readers already strip the CR of CR LF.

The workflow runs the script with both line endings on every native
target, and drops the per-command probe.
…I runs test.bat with its arguments, the machine runners are enabled on request
…mcpp run, and NetBSD and OpenBSD

- The platform of a row the built-in table does not serve is the one the package
  index names (openkal-platform, mcpp.platforms); only DJGPP's is stated.
- COMMAND.COM names cmain.c as its entry with its own define; the wrapper is gone.
- mcpp.plugins 0.22.1, the version openkal-platform 0.29.1 builds with.
- CI: setup-mcpp; FreeBSD, NetBSD, OpenBSD, Android, UEFI and both DOS rows run
  test.bat through `mcpp run --file` (the openkal DOS row now runs it: its stack
  is 1 MiB); UEFI and openkal DOS run it without its part that writes files; the
  openkal package runs in FreeBSD through its own launcher.
…e's default, 0.28.0, builds with mcpp.plugins 0.20.0); djgpp-platform 0.2.0, whose runner delivers test.bat
….30.0, run under an emulation of the interface
…ach system's base and run in its image

mcpp/platforms/hurd and mcpp/platforms/haiku each state a row, the base
system it is built over (xim's x86_64-hurd-sysroot: Debian GNU/Hurd's glibc;
x86_64-haiku-sysroot: Haiku's libroot, both with GCC's run-time) and the
machine it is run in (hurd-disk-image, haiku-disk-image, booted by dirun
0.7.0). The workflow builds both on Linux and runs test.bat in each system.
…s release build

On a Linux machine the Darwin row's runner boots PureDarwin (xnu with no
macOS above it) from the image its project publishes (xim's
puredarwin-disk-image: a developer preview, not mirrored) and runs test.bat
there. The row links openkal-macos 0.23.5, taken from its repository by tag,
which calls only the parts of fork the system library exports. The release
build links since openkal-macos 0.23.4, so the row is built as the others.
…nce the prompt is shown

UEFI (openkal-uefi 0.11.2) and openkal DOS now make, rename, list and
remove files as the script asks, so neither leaves that part out. DOS
without long names keeps a name in upper case (F1.TXT for f1.txt), so the
DOS row's output is compared without regard to case (check.sh,
CHECK_FOLD_CASE=1).

prompt.py typed each line after a fixed wait; under node the interpreter
had not yet shown its prompt, the terminal echoed the line ahead of the
banner, and the line's output followed the prompt on one line (seen once on
ubuntu-24.04). Each line is now typed once the prompt is shown.
…nd Haiku from mcpp.platforms 0.2.0

The System V row (openkal-platform 0.30.1) is run on AT&T UNIX System
V/386 Release 4.0 Version 3.0 in QEMU: xim's svr4-disk-image (technical
verification only: the system is proprietary), booted by dirun 0.8.0, whose
files disk carries the system's own label. mcpp.toml states that runner for
i686-svr4-musl; the platform's own runner, an emulation of the interface
(ibcs-us), is replaced, and the workflow no longer opens a user namespace.

GNU/Hurd and Haiku are rows of mcpp.platforms 0.2.0, which the package index
names for them, so mcpp/platforms/ is removed. The Hurd row is built over
Debian GNU/Hurd's base at the versions of the image it runs in
(x86_64-hurd-sysroot 20260314); both bases state GCC's std module.
On a GitHub-hosted runner the kernel of AT&T UNIX System V/386 Release 4.0
Version 3.0 stopped while it booted under KVM (the machine reset just after
"Booting the UNIX System...", which dirun's -no-reboot ends). Under TCG the
same run, through the packages the index publishes, is as expected in about
nine seconds on a developer machine. The PureDarwin runner names TCG the
same way.
The engine's own rows take mcpp's default (0.29.2); the rows the index names
the platform for (i686-linux-musl, i686-openkal, x86_64-uefi, i686-dos-musl)
take the index's release, 0.30.1, as run 44457199530 shows. The comment named
UEFI among the first.
…SPEC%) where one can be started

test.bat gains a part that starts "%COMSPEC%" /c exit 3 and prints the
status it ended with: cmd exports COMSPEC as its own path, so the part
needs no program of the host. It is left out (prepare.sh: the part and its
line of output) where no program can be started, measured: WebAssembly in
node and in the browser (no processes), an openkal image under okrun (it
starts a program, okrun itself as its own name, and an image it starts by
name ends by SIGSEGV: mcpplibs/openkal-image#42), UEFI and openkal DOS (no
openkal.process), DJGPP (no fork), and System V until its row claims
openkal.process (openkal-svr4 0.3.0; measured there on the kernel with the
0.26 branches: the status comes back).
There the interpreter does not find a program named by a path with a drive
letter: 'C:/Windows/system32/cmd.exe' is not recognized (run 44486548876),
while x86_64-windows-gnu starts it and reads its status.
…es; there the script starts no program

The runner names xim's puredarwin-disk-image 25.5-20261118-1 (openxlings/
xim-pkgindex#1200): PureDarwin numbers its two disks in either order from
one boot to the next, and the profile of 25.5-20261118 read rdisk1, so a
run sometimes delivered nothing and the shell answered 127 for the program
(this cell failed so in runs 44451504427 and 44486548876). Measured: the
files delivered in 6 boots of 6.

In PureDarwin the script leaves its program start out (run_process: false):
openkal-macos reports mode 0100666 for every file there, no execute bit
(mcpplibs/openkal-macos#53), and the interpreter finds a program by that bit.
The same artifact on the Intel Mac (macos-x86_64) runs the whole script.
…mages (mcpp.platforms 0.2.1)

mcpp.platforms 0.2.1 gives both rows a runner: xim's [email protected] and [email protected], booted by dirun in qemu-system-aarch64's virt machine with EDK II, translated on the x86_64 runner. The index names 0.2.1 for the rows (mcpplibs/mcpp-index#842).
…26.1; System V starts programs

openkal-platform 0.31.0 (the openkal 0.26 family) is indexed, and the rows
the index names it for took it, whose build programs use mcpp.plugins 0.26.1:
with this project's 0.22.1 their builds stopped (a build loads one version
of a build dependency). mcpp 2026.11.18.1's default for its own rows, 0.29.2,
builds with 0.22.1. So every row openkal-platform serves states 0.31.0 here,
and the build dependency is 0.26.1: one release for all.

- System V: openkal-svr4 0.3.0 claims openkal.process and openkal.space; the
  row runs the whole script on the kernel, its program start included
  (measured: status 3 back).
- x86_64-macos-musl: the platform's openkal-macos 0.24.0 carries 0.23.5's
  weak binding of fork's private parts, so the tag override is gone
  (PureDarwin measured: the script as expected).
…usl and PureDarwin start programs

The interpreter decided whether a name may be started by stat's execute
bits. A system that keeps no execute permission reports none there:
Windows under openkal's C library, and PureDarwin, whose root volume is
ext4, which openkal-macos does not claim execute bits for
(mcpplibs/openkal-macos#53). access(X_OK) asks the system that decides,
and is the right question on Unix too (the owner's bit says nothing about
another user's file). lexec.c's search and lselfpath.c's argv[0] fallback
both ask it now.

Under openkal's C library (CMD_LIBC_MUSL):
- fork reports ENOSYS where openkal.space is absent (Windows): the program
  is started with posix_spawn instead, its argument zero in the system's
  spelling (cmd.exe takes a '/' in its own name for a switch);
- the search follows the system's conventions, which openkal states
  (kal_env_system): on Windows PATH is split on ';', a name with a volume
  is not searched for, and a name without a suffix is tried with each
  suffix PATHEXT lists, as the C library's own search does.

Measured: x86_64-windows-musl (wine) and PureDarwin (twice) give the whole
script, the program start included; linux-gnu, x86_64/i686-linux-musl
unchanged; every musl row builds; make -std=c89 gives main's two warnings.
CI: neither row leaves the program start out any more.
…AWN), no openkal call

9e3500b asked openkal (kal_env_system) whether the system's conventions
are Windows', to search PATH with ';' and PATHEXT and to spell a started
program's argument zero with '\'. That is not the interpreter's to ask:
its l-layer uses a POSIX.1 C library or Win32 (AGENTS.md), and a C library
that presents POSIX on another system (openkal-musl) answers the system's
conventions itself (its execvp and posix_spawnp search by them). Removed;
the search is the original one with access(X_OK).

posix_spawn where fork reports ENOSYS stays, under POSIX's own option
macro _POSIX_SPAWN rather than CMD_LIBC_MUSL. Every target builds (the
macOS rows wait for the index, mcpplibs/mcpp-index#847); make -std=c89
gives main's two warnings.
@Sunrisepeak

Copy link
Copy Markdown
Owner Author

Measured, recorded in #1 (commit message of the windows-musl CI change). Closing the temporary probe.

@Sunrisepeak
Sunrisepeak deleted the probe-windows-argv0 branch November 19, 2026 14:47
@github-actions

Copy link
Copy Markdown
PR Preview Action v1.8.2
Preview removed because the pull request was closed.
2026-11-19 14:51 UTC

Sunrisepeak added a commit that referenced this pull request Nov 19, 2026
…easured reason

Measured on windows-2022 (temporary draft PR #4): the POSIX build hands a
started program its own name with '/' for '\' (cdispatch.c, as a POSIX
program wants it), and Windows' cmd.exe reads that as switches ("The syntax
of the command is incorrect"); whoami.exe, started the same way, runs. The
start itself works (posix_spawn where fork reports ENOSYS). openkal passes
arguments unaltered by its specification (clause 7.6), so the spelling is
not the C library's to change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant