aboutsummaryrefslogtreecommitdiffstats
path: root/getpgrp.c
diff options
context:
space:
mode:
Diffstat (limited to 'getpgrp.c')
-rw-r--r--getpgrp.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/getpgrp.c b/getpgrp.c
new file mode 100644
index 0000000..f3e9c81
--- /dev/null
+++ b/getpgrp.c
@@ -0,0 +1,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;
+}