from Lite

This commit is contained in:
cgd 1995-02-27 10:49:50 +00:00
parent 5b9633ddd7
commit aeb457b1a7
4 changed files with 414 additions and 40 deletions

162
lib/libc/sys/ktrace.2 Normal file
View File

@ -0,0 +1,162 @@
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" 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.
.\"
.\" @(#)ktrace.2 8.1 (Berkeley) 6/4/93
.\"
.Dd June 4, 1993
.Dt KTRACE 2
.Os BSD 4
.Sh NAME
.Nm ktrace
.Nd process tracing
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <sys/ktrace.h>
.Ft int
.Fn ktrace "const char *tracefile" "int ops" "int trpoints" "int pid"
.Sh DESCRIPTION
The
.Fn ktrace
function enables or disables tracing of one or more processes.
Users may only trace their own processes.
Only the super-user can trace setuid or setgid programs.
.Pp
The
.Ar tracefile
gives the pathname of the file to be used for tracing.
The file must exist and be writable by the calling process.
All trace records are always appended to the file,
so the file must be truncated to zero length to discard
previous trace data.
If tracing points are being disabled (see KTROP_CLEAR below),
.Ar tracefile
may be NULL.
.Pp
The
.Nm ops
parameter specifies the requested ktrace operation.
The defined operations are:
.Bl -column KTRFLAG_DESCENDXXX -offset indent
.It KTROP_SET Enable trace points specified in Ar trpoints .
.It KTROP_CLEAR Disable trace points specified in Ar trpoints .
.It KTROP_CLEARFILE Stop all tracing.
.It KTRFLAG_DESCEND The tracing change should apply to the
specified process and all its current children.
.El
.Pp
The
.Nm trpoints
parameter specifies the trace points of interest.
The defined trace points are:
.Bl -column KTRFAC_SYSCALLXXX -offset indent
.It KTRFAC_SYSCALL Trace system calls.
.It KTRFAC_SYSRET Trace return values from system calls.
.It KTRFAC_NAMEI Trace name lookup operations.
.It KTRFAC_GENIO Trace all I/O (note that this option can
generate much output).
.It KTRFAC_PSIG Trace posted signals.
.It KTRFAC_CSW Trace context switch points.
.It KTRFAC_INHERIT Inherit tracing to future children.
.El
.Pp
Each tracing event outputs a record composed of a generic header
followed by a trace point specific structure.
The generic header is:
.Bd -literal
struct ktr_header {
int ktr_len; /* length of buf */
short ktr_type; /* trace record type */
pid_t ktr_pid; /* process id */
char ktr_comm[MAXCOMLEN+1]; /* command name */
struct timeval ktr_time; /* timestamp */
caddr_t ktr_buf;
};
.Ed
.Pp
The
.Nm ktr_len
field specifies the length of the
.Nm ktr_type
data that follows this header.
The
.Nm ktr_pid
and
.Nm ktr_comm
fields specify the process and command generating the record.
The
.Nm ktr_time
field gives the time (with microsecond resolution)
that the record was generated.
The
.Nm ktr_buf
is an internal kernel pointer and is not useful.
.Pp
The generic header is followed by
.Nm ktr_len
bytes of a
.Nm ktr_type
record.
The type specific records are defined in the
.Pa <sys/ktrace.h>
include file.
.Sh RETURN VALUES
On successful completion a value of 0 is returned.
Otherwise, a value of -1 is returned and
.Va errno
is set to show the error.
.Sh ERRORS
.Fn Ktrace
will fail if:
.Bl -tag -width ENAMETOOLONGAA
.It Bq Er ENOTDIR
A component of the path prefix is not a directory.
.It Bq Er EINVAL
The pathname contains a character with the high-order bit set.
.It Bq Er ENAMETOOLONG
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
.It Bq Er ENOENT
The named tracefile does not exist.
.It Bq Er EACCES
Search permission is denied for a component of the path prefix.
.It Bq Er ELOOP
Too many symbolic links were encountered in translating the pathname.
.It Bq Er EIO
An I/O error occurred while reading from or writing to the file system.
.El
.Sh SEE ALSO
.Xr ktrace 1 ,
.Xr kdump 1
.Sh HISTORY
A
.Nm ktrace
function call first appeared in
.Bx 4.4 .

129
lib/libc/sys/profil.2 Normal file
View File

@ -0,0 +1,129 @@
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Donn Seeley of BSDI.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" 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.
.\"
.\" @(#)profil.2 8.1 (Berkeley) 6/4/93
.\"
.Dd "June 4, 1993"
.Dt PROFIL 2
.Os
.Sh NAME
.Nm profil
.Nd control process profiling
.Sh SYNOPSIS
.Ft int
.Fn profil "char *samples" "int size" "int offset" "int scale"
.Sh DESCRIPTION
The
.Fn profil
function enables or disables
program counter profiling of the current process.
If profiling is enabled,
then at every clock tick,
the kernel updates an appropriate count in the
.Fa samples
buffer.
.Pp
The buffer
.Fa samples
contains
.Fa size
bytes and is divided into
a series of 16-bit bins.
Each bin counts the number of times the program counter
was in a particular address range in the process
when a clock tick occurred while profiling was enabled.
For a given program counter address,
the number of the corresponding bin is given
by the relation:
.Bd -literal -offset indent
[(pc - offset) / 2] * scale / 65536
.Ed
.Pp
The
.Fa offset
parameter is the lowest address at which
the kernel takes program counter samples.
The
.Fa scale
parameter ranges from 1 to 65536 and
can be used to change the span of the bins.
A scale of 65536 maps each bin to 2 bytes of address range;
a scale of 32768 gives 4 bytes, 16384 gives 8 bytes and so on.
Intermediate values provide approximate intermediate ranges.
A
.Fa scale
value of 0 disables profiling.
.Sh RETURN VALUES
If the
.Fa scale
value is nonzero and the buffer
.Fa samples
contains an illegal address,
.Fn profil
returns \-1,
profiling is terminated and
.Va errno
is set appropriately.
Otherwise
.Fn profil
returns 0.
.Sh FILES
.Bl -tag -width /usr/lib/gcrt0.o -compact
.It Pa /usr/lib/gcrt0.o
profiling C run-time startup file
.It Pa gmon.out
conventional name for profiling output file
.El
.Sh ERRORS
The following error may be reported:
.Bl -tag -width Er
.It Bq Er EFAULT
The buffer
.Fa samples
contains an invalid address.
.El
.Sh SEE ALSO
.Xr gprof 1
.\" .Sh HISTORY
.\" wish I knew... probably v7.
.Sh BUGS
This routine should be named
.Fn profile .
.Pp
The
.Fa samples
argument should really be a vector of type
.Fa "unsigned short" .
.Pp
The format of the gmon.out file is undocumented.

View File

@ -1,5 +1,5 @@
.\" Copyright (c) 1994 Winning Strategies, Inc.
.\" All rights reserved.
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@ -11,58 +11,69 @@
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by Winning Strategies, Inc.
.\" 4. The name of the author may not be used to endorse or promote products
.\" derived from this software without specific prior written permission
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" 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: setsid.2,v 1.1 1994/04/15 22:48:03 jtc Exp $
.\" @(#)setsid.2 8.1 (Berkeley) 6/4/93
.\"
.Dd April 15, 1994
.Dd "June 4, 1993"
.Dt SETSID 2
.Os
.Sh NAME
.Nm setsid
.Nd set session ID
.Nd create session and set process group ID
.Sh SYNOPSIS
.Fd #include <sys/types.h>
.Fd #include <unistd.h>
.Ft pid_t
.Fn setsid
.Fn setsid "void"
.Sh DESCRIPTION
If the current process is not a process group leader,
.Fn setsid
sets the process group ID and the session ID of the current process to
the process ID of the current process, and releases the process's
controlling terminal.
.Sh RETURN VALUES
Upon successful completion, the session ID of the current process is returned.
Otherwise, a value of (pid_t) \-1 is returned and
.Va errno
is set to indicate the error.
The
.Nm setsid
function creates a new session.
The calling process is the session leader of the new session, is the
process group leader of a new process group and has no controlling
terminal.
The calling process is the only process in either the session or the
process group.
.Pp
Upon successful completion, the
.Nm setsid
function returns the value of the process group ID of the new process
group, which is the same as the process ID of the calling process.
.Sh ERRORS
.Fn setsid
will fail and return an error if the following is true:
If an error occurs,
.Nm setsid
returns -1 and the global variable
.Va errno
is set to indicate the error, as follows:
.Bl -tag -width Er
.It Bq Er EPERM
The current process is already a process group leader,
or there are other processes whose process group ID is equal to the
process ID of the current process.
The calling process is already a process group leader, or the process
group ID of a process other than the calling process matches the process
ID of the calling process.
.El
.Sh SEE ALSO
.Xr getpid 2 ,
.Xr setpgid 2
.Xr setpgid 3 ,
.Xr tcgetpgrp 3 ,
.Xr tcsetpgrp 3
.Sh STANDARDS
.Fn setsid
is expected to conform to
.St -p1003.1-90 .
The
.Nm setsid
function is expected to be compliant with the
.St -p1003.1-88
specification.

72
lib/libc/sys/sigpending.2 Normal file
View File

@ -0,0 +1,72 @@
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Berkeley Software Design, Inc.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" 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.
.\"
.\" @(#)sigpending.2 8.3 (Berkeley) 1/12/94
.\"
.Dd January 12, 1994
.Dt SIGPENDING 2
.Os
.Sh NAME
.Nm sigpending
.Nd get pending signals
.Sh SYNOPSIS
.Fd #include <signal.h>
.Ft int
.Fn sigpending "sigset_t *set"
.Sh DESCRIPTION
The
.Nm sigpending
function returns a mask of the signals pending for delivery
to the calling process in the location indicated by
.Fa set .
Signals may be pending because they are currently masked,
or transiently before delivery (although the latter case is not
normally detectable).
.Sh RETURN VALUES
A 0 value indicated that the call succeeded. A \-1 return value
indicates an error occurred and
.Va errno
is set to indicated the reason.
.Sh ERRORS
The
.Nm sigpending
function does not currently detect any errors.
.Sh SEE ALSO
.Xr sigaction 2 ,
.Xr sigprocmask 2
.Sh STANDARDS
The
.Nm sigpending
function is defined by
.St -p1003.1-88 .