Plan 9 from Bell Labs’s /usr/web/sources/contrib/rsc/linuxemu/sysproc.c

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


#include <u.h>
#include <libc.h>
#include <ureg.h>
#include "linuxsys.h"
#include "linux.h"

SYSCALL(sys_exit)
{
	int n = ARG1;
	char buf[12];

	DPRINT("exit(%d)...\n", n);

	if(n == 0)
		exits(0);
	
	sprint(buf, "%d", n);
	exits(buf);
}

SYSCALL(sys_brk)
{
	static void *top;
	void *bk = (void*) ARG1;

	if(top == nil)
		top = bss;

	DPRINT("brk(%p)...", bk);
	if(bk < bss)
		RETURN(top);
	if(segbrk(bss, bk) == 0) {
		top = bk;
		RETURN(0);
	}
	RETURN(-ENOMEM);
}

SYSCALL(sys_fork)
{
	int r;

	DPRINT("fork()...");
	if((r = fork()) < 0)
		RETURN(-EAGAIN);
	RETURN(r);
}

SYSCALL(sys_getpid)
{
	DPRINT("getpid()...");
	RETURN(getpid());
}

SYSCALL(sys_getppid)
{
	DPRINT("getppid()...");
	RETURN(getppid());
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].