⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0767-0770.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Linux Complete Command Reference:System Calls:EarthWeb Inc.-</TITLE>

</HEAD>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!-- ISBN=0672311046 //-->

<!-- TITLE=Linux Complete Command Reference//-->

<!-- AUTHOR=Red Hat//-->

<!-- PUBLISHER=Macmillan Computer Publishing//-->

<!-- IMPRINT=Sams//-->

<!-- CHAPTER=02 //-->

<!-- PAGES=0737-0890 //-->

<!-- UNASSIGNED1 //-->

<!-- UNASSIGNED2 //-->



<P><CENTER>

<a href="0764-0766.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0771-0771.html">Next</A></CENTER></P>







<A NAME="PAGENUM-767"><P>Page 767</P></A>





<P>In addition to these errors, setpriority will fail with the following:

</P>



<TABLE>



<TR><TD>

EPERM

</TD><TD>

A process was located, but neither its effective nor real user ID matched the effective user

ID of the caller.

</TD></TR><TR><TD>

EACCES

</TD><TD>

A nonsuperuser attempted to lower a process priority.

</TD></TR></TABLE>



<P><B>

HISTORY

</B></P>



<P>These function calls appeared in BSD 4.2.

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

nice(1), fork(2), renice(8)

</PRE>

<!-- END CODE SNIP //-->



<P>BSD Man Page, 24 July 1993

</P>



<H3><A NAME="ch02_ 39">

getrlimit, getrusage, setrlimit

</A></H3>



<P>getrlimit, getrusage, setrlimit&#151;Get/set resource limits and usage

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE //-->

<PRE>

#include &lt;sys/time.h&gt;

#include &lt;sys/resource.h&gt;

#include &lt;unistd.h&gt;



int getrlimit (int resource, struct rlimit *rlim);

int getrusage (int who, struct rusage *usage);

int setrlimit (int resource, const struct rlimit *rlim);

</PRE>

<!-- END CODE //-->



<P><B>

DESCRIPTION

</B></P>



<P>getrlimit and setrlimit get and set resource limits.

resource should be one of the following:

</P>



<!-- CODE //-->

<PRE>

RLIMIT CPU /* CPU time in seconds */

RLIMIT FSIZE /* Maximum filesize */

RLIMIT DATA /* max data size */

RLIMIT STACK /* max stack size */

RLIMIT CORE /* max core file size */

RLIMIT RSS /* max resident set size */

RLIMIT NPROC /* max number of processes */

RLIMIT NOFILE /* max number of open files */

RLIMIT MEMLOCK /* max locked-in-memory address space*/

</PRE>

<!-- END CODE //-->



<P>A resource may be unlimited if you set the limit to

RLIM_INFINITY. RLIMIT_OFILE is the BSD name for

RLIMIT_NOFILE.

</P>



<P>The rlimit structure is defined as follows :

</P>



<!-- CODE SNIP //-->

<PRE>

struct rlimit

            {

                 int  rlim_cur;

                 int  rlim_max;

            };

</PRE>

<!-- END CODE SNIP //-->



<P>getrusage returns the current resource usages for a

who of either RUSAGE_SELF or RUSAGE_CHILDREN:

</P>



<!-- CODE //-->

<PRE >

struct rusage

            {

                 struct timeval ru_utime; /* user time used */

                 struct timeval ru_stime; /* system time used */

                 long ru_maxrss;          /* maximum resident set size */

                 long ru_ixrss;           /* integral shared memory size */

</PRE>

<!-- END CODE //-->







<A NAME="PAGENUM-768"><P>Page 768</P></A>





<!-- CODE //-->

<PRE>

                 long ru_idrss;           /* integral unshared data size */

                 long ru_isrss;           /* integral unshared stack size */

                 long ru_minflt;          /* page reclaims */

                 long ru_majflt;          /* page faults */

                 long ru_nswap;           /* swaps */

                 long ru_inblock;         /* block input operations */

                 long ru_oublock;         /* block output operations */

                 long ru_msgsnd;          /* messages sent */

                 long ru_msgrcv;          /* messages received */

                 long ru_nsignals;        /* signals received */

                 long ru_nvcsw;           /* voluntary context switches */

                 long ru_nivcsw;          /* involuntary context switches */

            };

</PRE>

<!-- END CODE //-->



<P><B>

RETURN VALUE

</B></P>



<P>On success, 0 is returned. On error, _1 is returned and

errno is set appropriately.

</P>



<P><B>

ERRORS

</B></P>



<TABLE>



<TR><TD>

EINVAL

</TD><TD>

getrlimit or setrlimit is called with a bad

resource. getrusage is called with a bad who.

</TD></TR><TR><TD>

EPERM

</TD><TD>

A nonsuperuser tries to use setrlimit() to increase the soft or hard limit above the

current hard limit, or a superuser tries to increase

RLIMIT_NOFILE above the current kernel maximum.

</TD></TR></TABLE>





<P><B>

CONFORMS TO

</B></P>



<P>BSD 4.3

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

ulimit(2), quota(2)

</PRE>

<!-- END CODE SNIP //-->



<P>Linux, 23 July 1993

</P>



<H3><A NAME="ch02_ 40">

getsid

</A></H3>



<P>getsid&#151;Gets session ID

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE SNIP //-->

<PRE>

#include &lt;unistd.h&gt;

pid_t getsid(void);

</PRE>

<!-- END CODE SNIP //-->



<P><B>

DESCRIPTION

</B></P>



<P>getsid(0) returns the session ID of the calling process.

getsid(p) returns the session ID of the process with process ID

p.

</P>



<P><B>

ERRORS

</B></P>



<P>On error, _1 will be returned. The only error that can happen is

ESRCH, when no process with process ID p was found.

</P>



<P><B>

CONFORMS TO

</B></P>



<P>This call is Linux specific.

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

setsid(2)

</PRE>

<!-- END CODE SNIP //-->



<P>Linux 1.3.85, 11 April 1996

</P>



<A NAME="PAGENUM-769"><P>Page 769</P></A>





<P>getsockopt, setsockopt

</P>



<H3><A NAME="ch02_ 41">

getsockname

</A></H3>



<P>getsockname&#151;Gets socket name

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE SNIP //-->

<PRE>

int getsockname(int s &quot;, struct sockaddr *&quot; name &quot;, int *&quot; namelen );

</PRE>

<!-- END CODE SNIP //-->



<P><B>

DESCRIPTION

</B></P>



<P>getsockname returns the current name for the specified socket. The

namelen parameter should be initialized to indicate

the amount of space pointed to by name. On return it contains the actual size of the name returned (in bytes).

</P>



<P><B>

RETURN VALUE

</B></P>



<P>On success, 0 is returned. On error, _1 is returned and

errno is set appropriately.

</P>



<P><B>

ERRORS

</B></P>



<TABLE>



<TR><TD>

EBADF

</TD><TD>

The argument s is not a valid descriptor.

</TD></TR><TR><TD>

ENOTSOCK

</TD><TD>

The argument s is a file, not a socket.

</TD></TR><TR><TD>

ENOBUFS

</TD><TD>

Insufficient resources were available in the system to perform the operation.

</TD></TR><TR><TD>

EFAULT

</TD><TD>

The name parameter points to memory not in a valid part of the process address space.

</TD></TR></TABLE>





<P><B>

HISTORY

</B></P>



<P>The getsockname function call appeared in BSD 4.2.

</P>



<P><B>

BUGS

</B></P>



<P>Names bound to sockets in the UNIX domain are inaccessible;

getsockname returns a 0-length name.

</P>



<P><B>

SEE ALSO

</B></P>



<!-- CODE SNIP //-->

<PRE>

bind(2), socket(2)

</PRE>

<!-- END CODE SNIP //-->



<P>BSD Man Page, 24 July 1993

</P>



<H3><A NAME="ch02_ 42">

getsockopt, setsockopt

</A></H3>



<P>getsockopt, setsockopt&#151;Get and set options on sockets

</P>



<P><B>

SYNOPSIS

</B></P>



<!-- CODE //-->

<PRE>

#include &lt;sys/types.h&gt;

#include &lt;sys/socket.h&gt;

int getsockopt(int s,intlevel,intoptname,void*optval,int*optlen);

int setsockopt(int s,intlevel,intoptname, const void *optval,intoptlen);

</PRE>

<!-- END CODE //-->



<P><B>

DESCRIPTION

</B></P>



<P>getsockopt and setsockopt manipulate the

options associated with a socket. Options may exist at multiple protocol

levels; they are always present at the uppermost socket level.

</P>



<P>When manipulating socket options, the level at which the option resides and the name of the option must be specified.

To manipulate options at the socket level, level is specified as

SOL_SOCKET. To manipulate options at any other level, the

protocol number of the appropriate protocol controlling the option is supplied. For example, to indicate that an option is to

be interpreted by the TCP protocol, level should be set to the protocol number of TCP; see

getprotoent(3).

</P>



<A NAME="PAGENUM-770"><P>Page 770</P></A>





<P>The parameters optval and optlen are used to access option values for

setsockopt. For getsockopt they identify a buffer

in which the value for the requested option(s) is to be returned. For

getsockopt, optlen is a value-result parameter,

initially containing the size of the buffer pointed to by

optval, and modified on return to indicate the actual size of the

value returned. If no option value is to be supplied or returned,

optval may be NULL.

</P>



<P>optname and any specified options are passed uninterpreted to the appropriate protocol module for interpretation.

The include file &lt;sys/socket.h&gt; contains definitions for socket-level options, described below. Options at other protocol

levels vary in format and name; consult the appropriate entries in section 4 of the manual.

</P>



<P>Most socket-level options utilize an int parameter for

optval. For setsockopt, the parameter should be nonzero to enable

a boolean option, or 0 if the option is to be disabled.

SO_LINGER uses a struct linger parameter, defined in

&lt;linux/socket.h&gt;, which specifies the desired state of the option and the linger interval (see below).

SO_SNDTIMEO and SO_RCVTIMEO use a struct timeval parameter, defined in

&lt;sys/time.h&gt;.

</P>



<P>The following options are recognized at the socket level. Except as noted, each may be examined with

getsockopt and set with setsockopt:

</P>



<TABLE>



<TR><TD>

SO_DEBUG

</TD><TD>

Enables recording of debugging information.

</TD></TR><TR><TD>

SO_REUSEADDR

</TD><TD>

Enables local address reuse.

</TD></TR><TR><TD>

SO_KEEPALIVE

</TD><TD>

Enables keep connections alive.

</TD></TR><TR><TD>

SO_DONTROUTE

</TD><TD>

Enables routing bypass for outgoing messages.

</TD></TR><TR><TD>

SO_LINGER

</TD><TD>

Linger on close if data present.

</TD></TR><TR><TD>

SO_BROADCAST

</TD><TD>

Enables permission to transmit broadcast messages.

</TD></TR><TR><TD>

SO_OOBINLINE

</TD><TD>

Enables reception of out-of-band data in band.

</TD></TR><TR><TD>

SO_SNDBUF

</TD><TD>

Sets buffer size for output.

</TD></TR><TR><TD>

SO_RCVBUF

</TD><TD>

Sets buffer size for input.

</TD></TR><TR><TD>

SO_SNDLOWAT

</TD><TD>

Sets minimum count for output.

</TD></TR><TR><TD>

SO_RCVLOWAT

</TD><TD>

Sets minimum count for input.

</TD></TR><TR><TD>

SO_SNDTIMEO

</TD><TD>

Sets time-out value for output.

</TD></TR><TR><TD>

SO_RCVTIMEO

</TD><TD>

Sets time-out value for input.

</TD></TR><TR><TD>

SO_TYPE

</TD><TD>

Gets the type of the socket (get only).

</TD></TR><TR><TD>

SO_ERROR

</TD><TD>

Gets and clears error on the socket (get only).

</TD></TR></TABLE>





<P>SO_DEBUG enables debugging in the underlying protocol modules.

</P>



<P>SO_REUSEADDR indicates that the rules used in validating addresses supplied in a

bind(2) call should allow reuse of local addresses.

</P>



<P>SO_KEEPALIVE enables the periodic transmission of messages on a connected socket. Should the connected party fail

to respond to these messages, the connection is considered broken and processes using the socket are notified via a

SIGPIPE signal when attempting to send data.

</P>



<P>SO_DONTROUTE indicates that outgoing messages should bypass the standard routing facilities. Instead, messages are directed

to the appropriate network interface according to the network portion of the destination address.

<P>SO_LINGER controls the action taken when unsent messages are queued on socket and a

close(2) is performed. If the socket promises reliable delivery of data and

SO_LINGER is set, the system will block the process on the close attempt until it is able

to transmit the data or until it decides it is unable to deliver the information (a time-out period, termed the linger interval,

is specified in the setsockopt call when SO_LINGER is requested). If

SO_LINGER is disabled and a close is issued, the system

will process the close in a manner that allows the process to continue as quickly as possible.

</P>



<P>The linger structure is defined in

&lt;linux/socket.h&gt; as follows:

</P>



<!-- CODE SNIP //-->

<PRE>

struct linger {

                      int  l_onoff;   /* Linger active */

                      int  l_linger;  /* How long to linger for */

              };

</PRE>

<!-- END CODE SNIP //-->









<P><CENTER>

<a href="0764-0766.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0771-0771.html">Next</A></CENTER></P>







</td>
</tr>
</table>

<!-- begin footer information -->







</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -