Commit | Line | Data |
---|---|---|
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 | |
11 | gethostname, sethostname \- get/set name of current host | |
12 | .SH SYNOPSIS | |
13 | .nf | |
14 | .ft B | |
15 | gethostname(name, namelen) | |
16 | char *name; | |
17 | int namelen; | |
18 | .PP | |
19 | .ft B | |
20 | sethostname(name, namelen) | |
21 | char *name; | |
22 | int namelen; | |
23 | .fi | |
24 | .SH DESCRIPTION | |
25 | .I Gethostname | |
26 | returns the standard host name for the current processor, as | |
27 | previously set by | |
28 | .IR sethostname . | |
29 | The parameter | |
30 | .I namelen | |
31 | specifies the size of the | |
32 | .I name | |
33 | array. The returned name is null-terminated unless insufficient | |
34 | space is provided. | |
35 | .PP | |
36 | .I Sethostname | |
37 | sets the name of the host machine to be | |
38 | .IR name , | |
39 | which has length | |
40 | .IR namelen . | |
41 | This call is restricted to the super-user and | |
42 | is normally used only when the system is bootstrapped. | |
43 | .SH "RETURN VALUE | |
44 | If the call succeeds a value of 0 is returned. If the call | |
45 | fails, then a value of \-1 is returned and an error code is | |
9570e264 | 46 | placed in the global location \fIerrno\fP. |
6712d93b KM |
47 | .SH "ERRORS |
48 | The following errors may be returned by these calls: | |
49 | .TP 15 | |
50 | [EFAULT] | |
51 | The \fIname\fP or \fInamelen\fP parameter gave an | |
52 | invalid address. | |
53 | .TP 15 | |
54 | [EPERM] | |
fd690c8b | 55 | The caller tried to set the hostname and was not the super-user. |
6712d93b KM |
56 | .SH SEE ALSO |
57 | gethostid(2) | |
58 | .SH BUGS | |
a9172a1e MK |
59 | Host names are limited to MAXHOSTNAMELEN (from |
60 | .IR <sys/param.h> ) | |
61 | characters, currently 64. |