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

Copyright © 2009 Alcatel-Lucent.
Distributed under the Lucent Public License version 1.02.
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);
}

(This is a user-contributed directory and
should not be interpreted as statement by Alcatel-Lucent.)

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2009 Alcatel-Lucent. All Rights Reserved.
Comments to webmaster@plan9.bell-labs.com.