📄 0760-0763.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="0757-0759.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0764-0766.html">Next</A></CENTER></P>
<A NAME="PAGENUM-760"><P>Page 760</P></A>
<H3><A NAME="ch02_ 28">
getdomainname, setdomainname
</A></H3>
<P>getdomainname, setdomainname—Gets/sets domain name
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
int getdomainname(char *name, size_t len);
int setdomainname(const char *name, size_t len);
</PRE>
<!-- END CODE SNIP //-->
<P><B>
DESCRIPTION
</B></P>
<P>These functions are used to access or to change the domain name of the current processor.
</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>
EINVAL
</TD><TD>
For getdomainname, name points to
NULL or name is longer than len.
</TD></TR><TR><TD>
EPERM
</TD><TD>
For setdomainname, the caller was not the superuser.
</TD></TR><TR><TD>
EINVAL
</TD><TD>
For setdomainname, len was too long.
</TD></TR></TABLE>
<P><B>
CONFORMS TO
</B></P>
<P>POSIX does not specify these calls.
</P>
<P><B>
BUGS
</B></P>
<P>getdomainname is not compliant with other implementations because they always return
len bytes, even if name is longer. Linux, however, returns
EINVAL in this case (as of DLL 4.4.1 libraries).
</P>
<P><B>
NOTES
</B></P>
<P>Under Linux, getdomainname is implemented at the library level by calling
uname(2).
</P>
<P><B>
SEE ALSO
</B></P>
<!-- CODE SNIP //-->
<PRE>
gethostname(2), sethostname(2), uname(2)
</PRE>
<!-- END CODE SNIP //-->
<P>Linux 0.99.11, 22 July 1993
</P>
<H3><A NAME="ch02_ 29">
getdtablesize
</A></H3>
<P>getdtablesize—Gets descriptor table size
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
int getdtablesize(void);
</PRE>
<!-- END CODE SNIP //-->
<P><B>
DESCRIPTION
</B></P>
<P>getdtablesize returns the maximum number of files a process can have open.
</P>
<P><B>
NOTES
</B></P>
<P>getdtablesize is implemented as a library function in DLL 4.4.1. This function returns
OPEN_MAX (set to 256 in Linux 0.99.11) if OPEN_MAX was defined when the library was compiled. Otherwise,
_1 is returned and errno is set to ENOSYS.
</P>
<A NAME="PAGENUM-761"><P>Page 761</P></A>
<P><B>
SEE ALSO
</B></P>
<!-- CODE SNIP //-->
<PRE>
close(2), dup(2), open(2)
</PRE>
<!-- END CODE SNIP //-->
<P>Linux 0.99.11, 22 July 1993
</P>
<H3><A NAME="ch02_ 30">
getgid, getegid
</A></H3>
<P>getgid, getegid—Gets group identity
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
gid_t getgid(void);
gid_t getegid(void);
</PRE>
<!-- END CODE SNIP //-->
<P><B>
DESCRIPTION
</B></P>
<P>getgid returns the real group ID of the current process.
<P>getegid returns the effective group ID of the current process.
</P>
<P>The real ID corresponds to the ID of the calling process. The effective ID corresponds to the set ID bit on the file
being executed.
</P>
<P><B>
ERRORS
</B></P>
<P>These functions are always successful.
</P>
<P><B>
CONFORMS TO
</B></P>
<P>POSIX, BSD 4.3
</P>
<P><B>
SEE ALSO
</B></P>
<P>setregid(2), setgid(2)
</P>
<P>Linux 0.99.11, 23 July 1993
</P>
<H3><A NAME="ch02_ 31">
getgroups, setgroups
</A></H3>
<P>getgroups, setgroups—Gets/sets group access list
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
int getgroups(int size, gid_t list[]);
#define_USE_BSD
#include <grp.h>
int setgroups(size_t size, const gid_t *list);
</PRE>
<!-- END CODE SNIP //-->
<P><B>
DESCRIPTION
</B></P>
<TABLE>
<TR><TD>
getgroups
</TD><TD>
Up to size supplemental groups are returned in
list. If size is 0, list is not modified, but the total number of supplemental groups for the process is returned.
</TD></TR><TR><TD>
setgroups
</TD><TD>
Sets the supplemental groups for the process. Only the superuser may use this function.
</TD></TR></TABLE>
<A NAME="PAGENUM-762"><P>Page 762</P></A>
<P><B>
RETURN VALUE
</B></P>
<TABLE>
<TR><TD>
getgroups
</TD><TD>
On success, the number of groups stored in
list is returned (if size is 0, however, the number of supplemental group IDs associated with the process is returned). On error,
_1 is returned and errno is set appropriately.
</TD></TR><TR><TD>
setgroups
</TD><TD>
On success, 0 is returned. On error,
_1 is returned and errno is set appropriately.
</TD></TR></TABLE>
<P><B>
ERRORS
</B></P>
<TABLE>
<TR><TD>
EFAULT
</TD><TD>
list has an invalid address.
</TD></TR><TR><TD>
EPERM
</TD><TD>
For setgroups, the user is not the superuser.
</TD></TR><TR><TD>
EINVAL
</TD><TD>
For setgroups, gidsetsize is greater than
NGROUPS (32 for Linux 0.99.11).
</TD></TR></TABLE>
<P><B>
CONFORMS TO
</B></P>
<P>getgroups conforms to POSIX.1 (and is present in BSD 4.3). Since
setgroups requires privilege, it is not covered
under POSIX.1.
</P>
<P><B>
BUGS
</B></P>
<P>The USE BSD flag probably shouldn't be required for
setgroups.
</P>
<P><B>
SEE ALSO
</B></P>
<!-- CODE SNIP //-->
<PRE>
initgroups(3)
</PRE>
<!-- END CODE SNIP //-->
<P>Linux 0.99.11, 23 July 1993
</P>
<H3><A NAME="ch02_ 32">
gethostid, sethostid
</A></H3>
<P>gethostid, sethostid—Gets/sets the unique identifier of the current host
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
long int gethostid(void);
int sethostid(long int hostid);
</PRE>
<!-- END CODE SNIP //-->
<P><B>
DESCRIPTION
</B></P>
<P>Get or set a unique 32-bit identifier for the current machine. The 32-bit identifier is intended to be unique among all
UNIX systems in existence. This normally resembles the Internet address for the local machine, as returned by
gethostbyname(3), and thus usually never needs to be set.
</P>
<P>The sethostid call is restricted to the superuser.
</P>
<P>The hostid argument is stored in the file
/etc/hostid.
</P>
<P><B>
RETURNS VALUES
</B></P>
<P>gethostid returns the 32-bit identifier for the current host as set by
sethostid(2).
</P>
<P><B>
CONFORMS TO
</B></P>
<P>POSIX.1 does not define these functions, but ISO/IEC 9945-1:1990 mentions them in B.4.4.1.
</P>
<P><B>
FILES
</B></P>
<!-- CODE SNIP //-->
<PRE>
/etc/hostid
</PRE>
<!-- END CODE SNIP //-->
<A NAME="PAGENUM-763"><P>Page 763</P></A>
<P><B>
SEE ALSO
</B></P>
<!-- CODE SNIP //-->
<PRE>
hostid(1), gethostbyname(3)
</PRE>
<!-- END CODE SNIP //-->
<P>Linux 0.99.13, 29 November 1993
</P>
<H3><A NAME="ch02_ 33">
gethostname, sethostname
</A></H3>
<P>gethostname, sethostname—Gets/sets hostname
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <unistd.h>
int gethostname(char *name, size_t len);
int sethostname(const char *name, size_t len);
</PRE>
<!-- END CODE SNIP //-->
<P><B>
DESCRIPTION
</B></P>
<P>These functions are used to access or to change the hostname of the current processor.
</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>
EINVAL
</TD><TD>
len is negative or, for sethostname, larger than the maximum allowed size. For
gethostname on Linux/i386, len is smaller than the actual size.
</TD></TR><TR><TD>
EPERM
</TD><TD>
For sethostname, the caller was not the superuser.
</TD></TR><TR><TD>
EFAULT
</TD><TD>
name is an invalid address.
</TD></TR></TABLE>
<P><B>
CONFORMS TO
</B></P>
<P>POSIX.1 does not define these functions, but ISO/IEC 9945-1:1990 mentions them in B.4.4.1.
</P>
<P><B>
BUGS
</B></P>
<P>Some other implementations of gethostname successfully return
len bytes even if name is longer. Linux/Alpha complies
with this behavior. Linux/i386, however, returns
EINVAL in this case (as of DLL 4.6.27 libraries).
</P>
<P><B>
NOTES
</B></P>
<P>Under Linux/Alpha, gethostname is a system call. Under Linux/i386,
gethostname is implemented at the library level by calling
uname(2).
</P>
<P><B>
SEE ALSO
</B></P>
<!-- CODE SNIP //-->
<PRE>
getdomainname(2), setdomainname(2), uname(2)
</PRE>
<!-- END CODE SNIP //-->
<P>Linux 1.3.6, 22 July 1995
</P>
<H3><A NAME="ch02_ 34">
getitimer, setitimer
</A></H3>
<P>getitimer, setitimer—Gets/sets value of an interval timer
</P>
<P><B>
SYNOPSIS
</B></P>
<!-- CODE SNIP //-->
<PRE>
#include <sys/time.h>
int getitimer(int which, struct itimerval *value);
int setitimer(int which,conststruct itimer-val *value, struct itimerval *ovalue);
</PRE>
<!-- END CODE SNIP //-->
<P><CENTER>
<a href="0757-0759.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0764-0766.html">Next</A></CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -