aboutsummaryrefslogtreecommitdiffstats
path: root/getpgrp.c
blob: f3e9c81f88160a1aa5f7ac20ed8e570c78f15068 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#include "arg.h"


char *argv0;

int
main(int argc, char *argv[])
{
	ARGBEGIN {
	default:
		goto usage;
	} ARGEND;
	if (argc)
		goto usage;

	printf("%ji\n", (intmax_t)getpgrp());
	if (fflush(stdout) || ferror(stdout) || fclose(stdout)) {
		fprintf(stderr, "%s: printf: %s\n", argv0, strerror(errno));
		return 1;
	}

	return 0;

usage:
	fprintf(stderr, "usage: %s\n", argv0);
	return 1;
}