~sircmpwn/hare-users

2 2

Exit status of an exec::start process

Details
Message ID
<87h6rlvrxh.fsf@greenfork.me>
DKIM signature
missing
Download raw message
Hi,

Why does this code print 256 and exits with 0 status? I would expect it
to print 1 and exit with status 1.

	use fmt;
	use os;
	use os::exec;
	
	export fn main() void = {
		let cmd = exec::cmd("false")!;
		let proc = exec::start(&cmd)!;
		let status = exec::wait(&proc)!;
		fmt::printfln("Status: {}", status.status)!;
		os::exit(status.status);
	};
Details
Message ID
<CT4XY93EPNI7.3O1HW9C9FAQTE@desktop>
In-Reply-To
<87h6rlvrxh.fsf@greenfork.me> (view parent)
DKIM signature
missing
Download raw message
Hi,

> let status = exec::wait(&proc)!;
> fmt::printfln("Status: {}", status.status)!;

status.status is a bit confusing. This field includes some flags
(whether the process exited by itself or was signalled externally)
alongside the actual exit code/signal.

You probably want to use exec::exit(&status) or exec::check(&status) to
decode that field.
Details
Message ID
<87cz29v0tm.fsf@greenfork.me>
In-Reply-To
<CT4XY93EPNI7.3O1HW9C9FAQTE@desktop> (view parent)
DKIM signature
missing
Download raw message
That worked great, thank you!
Reply to thread Export thread (mbox)