POSIX return is pid_t
[unix-history] / usr / src / lib / libc / gen / gethostname.3
CommitLineData
88b3ccf2
KB
1.\" Copyright (c) 1983 The Regents of the University of California.
2.\" All rights reserved.
6712d93b 3.\"
91cff1e1 4.\" %sccs.include.redist.man%
88b3ccf2 5.\"
91cff1e1 6.\" @(#)gethostname.3 6.6 (Berkeley) %G%
6712d93b 7.\"
4d772387 8.TH GETHOSTNAME 2 ""
6712d93b
KM
9.UC 5
10.SH NAME
11gethostname, sethostname \- get/set name of current host
12.SH SYNOPSIS
13.nf
14.ft B
15gethostname(name, namelen)
16char *name;
17int namelen;
18.PP
19.ft B
20sethostname(name, namelen)
21char *name;
22int namelen;
23.fi
24.SH DESCRIPTION
25.I Gethostname
26returns the standard host name for the current processor, as
27previously set by
28.IR sethostname .
29The parameter
30.I namelen
31specifies the size of the
32.I name
33array. The returned name is null-terminated unless insufficient
34space is provided.
35.PP
36.I Sethostname
37sets the name of the host machine to be
38.IR name ,
39which has length
40.IR namelen .
41This call is restricted to the super-user and
42is normally used only when the system is bootstrapped.
43.SH "RETURN VALUE
44If the call succeeds a value of 0 is returned. If the call
45fails, then a value of \-1 is returned and an error code is
9570e264 46placed in the global location \fIerrno\fP.
6712d93b
KM
47.SH "ERRORS
48The following errors may be returned by these calls:
49.TP 15
50[EFAULT]
51The \fIname\fP or \fInamelen\fP parameter gave an
52invalid address.
53.TP 15
54[EPERM]
fd690c8b 55The caller tried to set the hostname and was not the super-user.
6712d93b
KM
56.SH SEE ALSO
57gethostid(2)
58.SH BUGS
a9172a1e
MK
59Host names are limited to MAXHOSTNAMELEN (from
60.IR <sys/param.h> )
61characters, currently 64.