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