shithub: riscv

ref: 19cc46bc5ee1dd43537c4094d19d8da778b72bce
dir: /sys/src/ape/lib/ap/plan9/getpgrp.c/

View raw version
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include "sys9.h"
#include "lib.h"

pid_t
getpgrp(void)
{
	int n, f, pid;
	char pgrpbuf[15], fname[30];

	pid = getpid();
	sprintf(fname, "/proc/%d/noteid", pid);
	f = open(fname, 0);
	n = read(f, pgrpbuf, sizeof pgrpbuf);
	if(n < 0)
		_syserrno();
	else
		n = atoi(pgrpbuf);
	close(f);
	return n;
}