Use err(3). Sync usage string and man page.
This commit is contained in:
parent
1e96bb57a6
commit
7f1550ed10
@ -28,7 +28,7 @@
|
||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $Id: rtprio.1,v 1.10 1997/03/07 07:43:19 mpp Exp $
|
||||
.\" $Id: rtprio.1,v 1.11 1997/03/07 07:45:17 mpp Exp $
|
||||
.\"
|
||||
.Dd July 23, 1994
|
||||
.Dt RTPRIO 1
|
||||
@ -41,7 +41,7 @@ or idletime scheduling priority
|
||||
.Sh SYNOPSIS
|
||||
.Nm [id|rt]prio
|
||||
.Nm [id|rt]prio
|
||||
.Ar pid
|
||||
.Ar [-]pid
|
||||
.Nm [id|rt]prio
|
||||
.Ar priority
|
||||
.Ar command
|
||||
@ -63,7 +63,7 @@ is used for controlling realtime process scheduling.
|
||||
.Nm Idprio
|
||||
is used for controlling idletime process scheduling, and can be called
|
||||
with the same options as
|
||||
.Nm Rtprio .
|
||||
.Nm rtprio .
|
||||
.Pp
|
||||
A process with a realtime priority is not subject to priority
|
||||
degradation, and will only be preempted by another process of equal or
|
||||
@ -75,12 +75,12 @@ greater than all other runnable idle priority processes.
|
||||
.Pp
|
||||
.Nm Rtprio
|
||||
or
|
||||
.Nm Idprio
|
||||
.Nm idprio
|
||||
when called without arguments will return the realtime priority
|
||||
of the current process.
|
||||
.Pp
|
||||
If
|
||||
.Nm rtprio
|
||||
.Nm
|
||||
is called with 1 argument, it will return the realtime priority
|
||||
of the process with the specified
|
||||
.Ar pid .
|
||||
@ -95,8 +95,9 @@ process.
|
||||
.Pp
|
||||
If
|
||||
.Ar -pid
|
||||
is specified, the process with the process identifier "pid" will be
|
||||
modified, else if
|
||||
is specified, the process with the process identifier
|
||||
.Ar pid
|
||||
will be modified, else if
|
||||
.Ar command
|
||||
is specified, that program is run with its arguments.
|
||||
.Pp
|
||||
@ -111,7 +112,7 @@ Only root is allowed to set realtime priorities. Non-root processes may
|
||||
set idle priority levels for the current process only.
|
||||
.Sh RETURN VALUE
|
||||
If
|
||||
.Nm rtprio
|
||||
.Nm
|
||||
execute a command, the exit value is that of the command executed.
|
||||
In all other cases,
|
||||
.Nm
|
||||
@ -154,7 +155,7 @@ To change the realtime priority of process
|
||||
.Em 1423
|
||||
to
|
||||
.Dv RTP_PRIO_NORMAL
|
||||
(non-realtime/"normal" priority):
|
||||
(non-realtime/normal priority):
|
||||
.Bd -literal -offset indent -compact
|
||||
.Sy "rtprio -t -1423"
|
||||
.Ed
|
||||
@ -172,7 +173,7 @@ To make depend while not disturbing other machine usage:
|
||||
.Xr renice 8
|
||||
.Sh HISTORY
|
||||
The
|
||||
.Nm rtprio
|
||||
.Nm
|
||||
utility appeared in
|
||||
.Fx 2.0 ,
|
||||
but is similar to the HP-UX version.
|
||||
@ -185,19 +186,21 @@ There is no way to set/view the realtime priority of process 0
|
||||
.Xr ps 1 ) .
|
||||
.Pp
|
||||
There is in
|
||||
.Tn FreeBSD
|
||||
.Bx Free
|
||||
no way to ensure that a process page is present in memory therefore
|
||||
the process may be stopped for pagein. (See
|
||||
the process may be stopped for pagein (see
|
||||
.Xr mprotect 2 ,
|
||||
.Xr madvise 2 ) .
|
||||
.Pp
|
||||
Under
|
||||
.Tn FreeBSD
|
||||
.Bx Free
|
||||
system calls are currently never preempted, therefore non-realtime
|
||||
processes can starve realtime processes, or idletime processes can
|
||||
starve normal priority processes.
|
||||
.Sh AUTHOR
|
||||
Henrik Vestergaard Draboel - hvd@terry.ping.dk is the original author. This
|
||||
.An Henrik Vestergaard Draboel Aq hvd@terry.ping.dk
|
||||
is the original author. This
|
||||
implementation in
|
||||
.Tn FreeBSD
|
||||
was substantially rewritten by David Greenman.
|
||||
.Bx Free
|
||||
was substantially rewritten by
|
||||
.An David Greenman .
|
||||
|
@ -30,18 +30,22 @@
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char rcsid[] =
|
||||
"$Id$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/rtprio.h>
|
||||
#include <sys/errno.h>
|
||||
|
||||
#include <ctype.h>
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static void usage();
|
||||
@ -72,10 +76,8 @@ main(argc, argv)
|
||||
* arg! */
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
if (rtprio(RTP_LOOKUP, proc, &rtp) != 0) {
|
||||
perror(argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
if (rtprio(RTP_LOOKUP, proc, &rtp) != 0)
|
||||
err(1, "%s", argv[0]);
|
||||
printf("%s: ", p);
|
||||
switch (rtp.type) {
|
||||
case RTP_PRIO_REALTIME:
|
||||
@ -99,44 +101,40 @@ main(argc, argv)
|
||||
rtp.type = RTP_PRIO_NORMAL;
|
||||
rtp.prio = 0;
|
||||
} else {
|
||||
usage(p);
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
rtp.prio = atoi(argv[1]);
|
||||
}
|
||||
} else {
|
||||
usage(p);
|
||||
usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if (argv[2][0] == '-')
|
||||
proc = -atoi(argv[2]);
|
||||
|
||||
if (rtprio(RTP_SET, proc, &rtp) != 0) {
|
||||
perror(argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
if (rtprio(RTP_SET, proc, &rtp) != 0)
|
||||
err(1, "%s", argv[0]);
|
||||
|
||||
if (proc == 0) {
|
||||
execvp(argv[2], &argv[2]);
|
||||
perror(argv[0]);
|
||||
exit (1);
|
||||
err(1, "%s", argv[0]);
|
||||
}
|
||||
}
|
||||
exit (1);
|
||||
}
|
||||
|
||||
static void
|
||||
usage(basename)
|
||||
char *basename;
|
||||
usage()
|
||||
{
|
||||
(void) fprintf(stderr, "usage: %s\n", basename);
|
||||
(void) fprintf(stderr, "usage: %s [-]pid\n", basename);
|
||||
(void) fprintf(stderr, "usage: %s priority command [ args ] \n", basename);
|
||||
(void) fprintf(stderr, "usage: %s priority -pid \n", basename);
|
||||
(void) fprintf(stderr, "usage: %s -t command [ args ] \n", basename);
|
||||
(void) fprintf(stderr, "usage: %s -t -pid \n", basename);
|
||||
|
||||
exit(-1);
|
||||
(void) fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
|
||||
"usage: [id|rt]prio",
|
||||
" [id|rt]prio [-]pid",
|
||||
" [id|rt]prio priority command [args]",
|
||||
" [id|rt]prio priority -pid",
|
||||
" [id|rt]prio -t command [args]",
|
||||
" [id|rt]prio -t -pid");
|
||||
exit(1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user