/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1992-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
static const char usage[] =
"[-?\n@(#)$Id: pids (AT&T Research) 2008-04-01 $\n]"
"[+NAME?pids - list calling shell process ids]"
"[+DESCRIPTION?When invoked as a shell builtin, \bpids\b lists one or "
"more of the calling process ids determined by \bgetpid\b(2), "
"\bgetppid\b(2), \bgetpgrp\b(2), \btcgetpgrp\b(2) and \bgetsid\b(2). "
"Unknown or invalid ids have the value \b-1\b.]"
"[f:format?List the ids specified by \aformat\a. \aformat\a follows "
"\bprintf\b(3) conventions, except that \bsfio\b(3) inline ids are used "
"instead of arguments: "
"%[-+]][\awidth\a[.\aprecis\a[.\abase\a]]]]]](\aid\a)\achar\a. The "
"{"
"[+pid?The process id.]"
"[+pgid?The process group id.]"
"[+ppid?The parent process id.]"
"[+tid|tty?The controlling terminal id.]"
"[+sid?The session id.]"
"}"
"[+SEE ALSO?\bgetpid\b(2), \bgetppid\b(2), \bgetpgrp\b(2), "
"\btcgetpgrp\b(2), \bgetsid\b(2)]"
;
#include <cmd.h>
#include <ast_tty.h>
#include <sfdisc.h>
/*
* sfkeyprintf() lookup
* handle==0 for heading
*/
static int
{
register char* s;
int fd;
long tid;
else if (streq(s, "pgid"))
else if (streq(s, "ppid"))
{
break;
}
else if (streq(s, "sid"))
else if (streq(s, "format"))
else
{
return 0;
}
return 1;
}
int
{
char* format = 0;
for (;;)
{
{
case 'f':
continue;
case '?':
break;
case ':':
break;
}
break;
}
if (!format)
return 0;
}