Plan 9 from Bell Labs’s /usr/web/sources/contrib/nemo/octopus/port/lib/error.b

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


implement Error;
include "sys.m";
	sys: Sys;
include "error.m";


kill(pid: int, msg: string): int
{
	fd := sys->open("/prog/"+string pid+"/ctl", Sys->OWRITE);
	if(fd == nil || sys->fprint(fd, "%s", msg) < 0)
		return -1;
	return 0;
}

checkload[T](x: T, p: string): T
{
	if(x == nil)
		error(sys->sprint("cannot load %s: %r", p));
	return x;
}

error(e: string)
{
	sys->fprint(stderr, "%s\n", e);
	raise "fail:error";
}

panic(e: string)
{
	sys->fprint(stderr, "panic: %s\n", e);
	raise "abort";
}

init()
{
	sys = load Sys Sys->PATH;
	stderr = sys->fildes(2);
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.