2016-01-06 22:57:32 +00:00
|
|
|
.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>,
|
|
|
|
.\" Copyright (C) 2008-2014, Michael Kerrisk <mtk.manpages@gmail.com>,
|
|
|
|
.\" and Copyright (C) 2016, Heinrich Schuchardt <xypron.glpk@gmx.de>
|
ldd.1, capget.2, clone.2, create_module.2, fallocate.2, futex.2, get_kernel_syms.2, get_thread_area.2, getcpu.2, getitimer.2, getpid.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl_list.2, mkdir.2, mknod.2, pciconfig_read.2, pivot_root.2, posix_fadvise.2, query_module.2, sendfile.2, set_thread_area.2, setns.2, unshare.2, __setfpucw.3, a64l.3, addseverity.3, argz_add.3, bindresvport.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, ccos.3, ccosh.3, cerf.3, cexp.3, cexp2.3, cimag.3, clog.3, clog10.3, clog2.3, cmsg.3, conj.3, cpow.3, cproj.3, creal.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, des_crypt.3, envz_add.3, fdim.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmtmsg.3, fpclassify.3, gamma.3, getpt.3, getrpcent.3, getrpcport.3, getttyent.3, isgreater.3, key_setsecret.3, lgamma.3, malloc_hook.3, mempcpy.3, nan.3, netlink.3, nextafter.3, putgrent.3, remove.3, remquo.3, rpc.3, rtime.3, rtnetlink.3, setaliasent.3, setnetgrent.3, signbit.3, significand.3, sincos.3, stdin.3, tgamma.3, xcrypt.3, xdr.3, cciss.4, hpsa.4, mouse.4, pts.4, sk98lin.4, tty_ioctl.4, wavelan.4, hosts.equiv.5, rpc.5, tzfile.5, boot.7, complex.7, ddp.7, fifo.7, futex.7, icmp.7, ip.7, ipv6.7, netdevice.7, netlink.7, packet.7, raw.7, rtnetlink.7, socket.7, tcp.7, udp.7, unix.7, x25.7, sync.8: Global fix: Put copyright info at top of page, followed by blank line and LICENSE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-10 09:29:51 +00:00
|
|
|
.\"
|
getcpu.2, sendfile.2, cmsg.3, rtnetlink.3, arp.7, ddp.7, fifo.7, icmp.7, ip.7, ipv6.7, netdevice.7, packet.7, raw.7, rtnetlink.7, socket.7, tcp.7, udp.7, unix.7, x25.7: LICENSE_START(VERBATIM_ONE_PARA)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-10 09:29:00 +00:00
|
|
|
.\" %%%LICENSE_START(VERBATIM_ONE_PARA)
|
2008-08-08 16:41:48 +00:00
|
|
|
.\" Permission is granted to distribute possibly modified copies
|
|
|
|
.\" of this page provided the header is included verbatim,
|
|
|
|
.\" and in case of nontrivial modification author and date
|
|
|
|
.\" of the modification is added to the header.
|
epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, fallocate.2, futex.2, getcpu.2, getitimer.2, ioctl_list.2, ioprio_set.2, migrate_pages.2, move_pages.2, pciconfig_read.2, sendfile.2, setns.2, signalfd.2, spu_create.2, spu_run.2, sysinfo.2, timerfd_create.2, backtrace.3, cmsg.3, error.3, getpt.3, getrpcent.3, getrpcport.3, getsubopt.3, offsetof.3, program_invocation_name.3, rpc.3, rpmatch.3, rtnetlink.3, xdr.3, cciss.4, hpsa.4, pts.4, charmap.5, dir_colors.5, elf.5, gai.conf.5, locale.5, nscd.conf.5, nss.5, resolv.conf.5, rpc.5, arp.7, cpuset.7, ddp.7, epoll.7, fifo.7, futex.7, icmp.7, ip.7, ipv6.7, mailaddr.7, netdevice.7, packet.7, raw.7, regex.7, rtnetlink.7, socket.7, spufs.7, tcp.7, udp.7, unix.7, x25.7, ldconfig.8, nscd.8: Global fix: s/END_LICENSE/LICENSE_END/
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-03-12 09:26:07 +00:00
|
|
|
.\" %%%LICENSE_END
|
2008-08-08 16:41:48 +00:00
|
|
|
.\"
|
|
|
|
.\" Modified, 2003-12-02, Michael Kerrisk, <mtk.manpages@gmail.com>
|
|
|
|
.\" Modified, 2003-09-23, Adam Langley
|
|
|
|
.\" Modified, 2004-05-27, Michael Kerrisk, <mtk.manpages@gmail.com>
|
|
|
|
.\" Added SOCK_SEQPACKET
|
|
|
|
.\" 2008-05-27, mtk, Provide a clear description of the three types of
|
|
|
|
.\" address that can appear in the sockaddr_un structure: pathname,
|
|
|
|
.\" unnamed, and abstract.
|
|
|
|
.\"
|
execve.2, fallocate.2, getrlimit.2, io_submit.2, membarrier.2, mmap.2, msgget.2, open.2, ptrace.2, readv.2, semget.2, shmget.2, shutdown.2, syscall.2, wait.2, wait4.2, crypt.3, encrypt.3, fseek.3, getcwd.3, makedev.3, pthread_create.3, puts.3, tsearch.3, elf.5, filesystems.5, group.5, passwd.5, sysfs.5, mount_namespaces.7, posixoptions.7, time.7, unix.7, vdso.7, xattr.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-30 15:41:31 +00:00
|
|
|
.TH UNIX 7 2018-04-30 "Linux" "Linux Programmer's Manual"
|
2008-08-08 16:41:48 +00:00
|
|
|
.SH NAME
|
intro.1, add_key.2, get_mempolicy.2, get_thread_area.2, intro.2, keyctl.2, mbind.2, request_key.2, set_thread_area.2, clock.3, cmsg.3, getcwd.3, getpw.3, intro.3, malloc.3, posix_memalign.3, shm_open.3, sleep.3, sysconf.3, intro.4, sd.4, intro.5, locale.5, slabinfo.5, intro.6, boot.7, bootparam.7, futex.7, glob.7, hier.7, intro.7, libc.7, locale.7, mq_overview.7, netlink.7, sem_overview.7, shm_overview.7, unix.7, intro.8: Global fix: Use consistent capitalization in NAME section
The line(s) in the NAME section should only use capitals
where English usage dictates that. Otherwise, use
lowercase throughout.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2012-10-21 06:29:13 +00:00
|
|
|
unix \- sockets for local interprocess communication
|
2008-08-08 16:41:48 +00:00
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <sys/socket.h>
|
|
|
|
.br
|
|
|
|
.B #include <sys/un.h>
|
_exit.2, accept.2, chmod.2, dup.2, getgroups.2, keyctl.2, link.2, mkdir.2, mknod.2, pipe.2, poll.2, reboot.2, rename.2, select.2, select_tut.2, stat.2, symlink.2, unlink.2, __ppc_get_timebase.3, abs.3, bzero.3, crypt.3, dbopen.3, dl_iterate_phdr.3, dlinfo.3, dlsym.3, duplocale.3, encrypt.3, err.3, ffs.3, fpurge.3, ftw.3, getdate.3, gethostbyname.3, getlogin.3, getmntent.3, getpwent_r.3, getpwnam.3, getspnam.3, inet_pton.3, insque.3, isfdtype.3, mallinfo.3, mallopt.3, matherr.3, mcheck.3, mempcpy.3, mkfifo.3, mq_getattr.3, newlocale.3, open_memstream.3, openpty.3, perror.3, posix_memalign.3, posix_spawn.3, printf.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setaffinity_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_sigqueue.3, regex.3, resolver.3, rpmatch.3, rtnetlink.3, scanf.3, setbuf.3, strchr.3, strfromd.3, strverscmp.3, termios.3, tsearch.3, unlocked_stdio.3, updwtmp.3, netlink.7, rtld-audit.7, sock_diag.7, unix.7: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-15 15:44:09 +00:00
|
|
|
.PP
|
2008-08-08 16:47:53 +00:00
|
|
|
.IB unix_socket " = socket(AF_UNIX, type, 0);"
|
2008-08-08 16:41:48 +00:00
|
|
|
.br
|
2008-08-08 16:47:53 +00:00
|
|
|
.IB error " = socketpair(AF_UNIX, type, 0, int *" sv ");"
|
2008-08-08 16:41:48 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
The
|
2008-08-08 16:47:53 +00:00
|
|
|
.B AF_UNIX
|
2008-08-08 16:41:48 +00:00
|
|
|
(also known as
|
2008-08-08 16:47:53 +00:00
|
|
|
.BR AF_LOCAL )
|
2008-08-08 16:41:48 +00:00
|
|
|
socket family is used to communicate between processes on the same machine
|
|
|
|
efficiently.
|
2010-10-12 04:48:33 +00:00
|
|
|
Traditionally, UNIX domain sockets can be either unnamed,
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
or bound to a filesystem pathname (marked as being of type socket).
|
2008-08-08 16:41:48 +00:00
|
|
|
Linux also supports an abstract namespace which is independent of the
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
filesystem.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
Valid socket types in the UNIX domain are:
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR SOCK_STREAM ,
|
2012-04-17 10:56:21 +00:00
|
|
|
for a stream-oriented socket;
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR SOCK_DGRAM ,
|
|
|
|
for a datagram-oriented socket that preserves message boundaries
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
(as on most UNIX implementations, UNIX domain datagram
|
2008-08-08 16:41:48 +00:00
|
|
|
sockets are always reliable and don't reorder datagrams);
|
|
|
|
and (since Linux 2.6.4)
|
|
|
|
.BR SOCK_SEQPACKET ,
|
2016-01-08 19:44:17 +00:00
|
|
|
for a sequenced-packet socket that is connection-oriented,
|
|
|
|
preserves message boundaries,
|
2008-08-08 16:41:48 +00:00
|
|
|
and delivers messages in the order that they were sent.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2010-10-12 04:48:33 +00:00
|
|
|
UNIX domain sockets support passing file descriptors or process credentials
|
2008-08-08 16:41:48 +00:00
|
|
|
to other processes using ancillary data.
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Address format
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
A UNIX domain socket address is represented in the following structure:
|
ioctl_console.2, ioctl_getfsmap.2, ioctl_iflags.2, ioctl_list.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, link.2, mmap.2, modify_ldt.2, msgctl.2, poll.2, query_module.2, quotactl.2, recv.2, recvmmsg.2, sched_setscheduler.2, seccomp.2, select.2, semctl.2, semop.2, send.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sysinfo.2, timer_create.2, timerfd_create.2, uname.2, unshare.2, userfaultfd.2, ustat.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, backtrace.3, bswap.3, btree.3, clock_getcpuclockid.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, fmemopen.3, fopencookie.3, frexp.3, fts.3, ftw.3, getaddrinfo.3, getaddrinfo_a.3, getcontext.3, getgrouplist.3, getifaddrs.3, getipnodebyname.3, getnameinfo.3, getopt.3, getprotoent_r.3, getpwent_r.3, getrpcent.3, getservent_r.3, getttyent.3, getumask.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, inet.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallopt.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mtrace.3, newlocale.3, ntp_gettime.3, offsetof.3, posix_openpt.3, printf.3, pthread_setname_np.3, pthread_setschedparam.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, sigvec.3, stdarg.3, strcat.3, strcpy.3, strftime.3, strtol.3, toupper.3, ttyslot.3, fuse.4, loop.4, st.4, elf.5, cgroup_namespaces.7, cgroups.7, feature_test_macros.7, inode.7, inotify.7, keyrings.7, man-pages.7, math_error.7, mount_namespaces.7, mq_overview.7, pthreads.7, sched.7, session-keyring.7, udplite.7, unix.7, vdso.7: Use consistent markup for code snippets
The preferred form is
.PP/.IP
.in +4n
.EX
<code>
.EE
.in
.PP/.IP
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:37:55 +00:00
|
|
|
.PP
|
2008-08-08 16:41:48 +00:00
|
|
|
.in +4n
|
ioctl_console.2, ioctl_getfsmap.2, ioctl_iflags.2, ioctl_list.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, link.2, mmap.2, modify_ldt.2, msgctl.2, poll.2, query_module.2, quotactl.2, recv.2, recvmmsg.2, sched_setscheduler.2, seccomp.2, select.2, semctl.2, semop.2, send.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sysinfo.2, timer_create.2, timerfd_create.2, uname.2, unshare.2, userfaultfd.2, ustat.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, backtrace.3, bswap.3, btree.3, clock_getcpuclockid.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, fmemopen.3, fopencookie.3, frexp.3, fts.3, ftw.3, getaddrinfo.3, getaddrinfo_a.3, getcontext.3, getgrouplist.3, getifaddrs.3, getipnodebyname.3, getnameinfo.3, getopt.3, getprotoent_r.3, getpwent_r.3, getrpcent.3, getservent_r.3, getttyent.3, getumask.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, inet.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallopt.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mtrace.3, newlocale.3, ntp_gettime.3, offsetof.3, posix_openpt.3, printf.3, pthread_setname_np.3, pthread_setschedparam.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, sigvec.3, stdarg.3, strcat.3, strcpy.3, strftime.3, strtol.3, toupper.3, ttyslot.3, fuse.4, loop.4, st.4, elf.5, cgroup_namespaces.7, cgroups.7, feature_test_macros.7, inode.7, inotify.7, keyrings.7, man-pages.7, math_error.7, mount_namespaces.7, mq_overview.7, pthreads.7, sched.7, session-keyring.7, udplite.7, unix.7, vdso.7: Use consistent markup for code snippets
The preferred form is
.PP/.IP
.in +4n
.EX
<code>
.EE
.in
.PP/.IP
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:37:55 +00:00
|
|
|
.EX
|
2015-05-06 08:22:38 +00:00
|
|
|
.\" #define UNIX_PATH_MAX 108
|
2015-05-07 06:30:26 +00:00
|
|
|
.\"
|
2008-08-08 16:41:48 +00:00
|
|
|
struct sockaddr_un {
|
|
|
|
sa_family_t sun_family; /* AF_UNIX */
|
2018-07-15 07:57:11 +00:00
|
|
|
char sun_path[108]; /* Pathname */
|
2008-08-08 16:41:48 +00:00
|
|
|
};
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EE
|
2008-08-08 16:41:48 +00:00
|
|
|
.in
|
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
The
|
2008-08-08 16:41:48 +00:00
|
|
|
.I sun_family
|
2012-04-17 10:56:21 +00:00
|
|
|
field always contains
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR AF_UNIX .
|
2018-07-08 19:29:13 +00:00
|
|
|
On Linux,
|
2015-05-06 08:24:56 +00:00
|
|
|
.I sun_path
|
|
|
|
is 108 bytes in size; see also NOTES, below.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
Various systems calls (for example,
|
|
|
|
.BR bind (2),
|
|
|
|
.BR connect (2),
|
|
|
|
and
|
|
|
|
.BR sendto (2))
|
|
|
|
take a
|
2014-10-15 09:17:46 +00:00
|
|
|
.I sockaddr_un
|
2012-04-17 10:56:21 +00:00
|
|
|
argument as input.
|
|
|
|
Some other system calls (for example,
|
|
|
|
.BR getsockname (2),
|
|
|
|
.BR getpeername (2),
|
|
|
|
.BR recvfrom (2),
|
|
|
|
and
|
|
|
|
.BR accept (2))
|
|
|
|
return an argument of this type.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
Three types of address are distinguished in the
|
|
|
|
.I sockaddr_un
|
|
|
|
structure:
|
2008-08-08 16:41:48 +00:00
|
|
|
.IP * 3
|
|
|
|
.IR pathname :
|
2014-01-17 16:50:05 +00:00
|
|
|
a UNIX domain socket can be bound to a null-terminated
|
|
|
|
filesystem pathname using
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR bind (2).
|
2012-04-17 10:56:21 +00:00
|
|
|
When the address of a pathname socket is returned
|
|
|
|
(by one of the system calls noted above),
|
2008-08-08 16:41:48 +00:00
|
|
|
its length is
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2013-08-01 10:29:32 +00:00
|
|
|
offsetof(struct sockaddr_un, sun_path) + strlen(sun_path) + 1
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2008-08-08 16:41:48 +00:00
|
|
|
and
|
|
|
|
.I sun_path
|
|
|
|
contains the null-terminated pathname.
|
2012-04-17 10:56:21 +00:00
|
|
|
(On Linux, the above
|
|
|
|
.BR offsetof ()
|
|
|
|
expression equates to the same value as
|
|
|
|
.IR sizeof(sa_family_t) ,
|
|
|
|
but some other implementations include other fields before
|
|
|
|
.IR sun_path ,
|
|
|
|
so the
|
|
|
|
.BR offsetof ()
|
|
|
|
expression more portably describes the size of the address structure.)
|
|
|
|
.IP
|
|
|
|
For further details of pathname sockets, see below.
|
2008-08-08 16:41:48 +00:00
|
|
|
.IP *
|
|
|
|
.IR unnamed :
|
|
|
|
A stream socket that has not been bound to a pathname using
|
|
|
|
.BR bind (2)
|
|
|
|
has no name.
|
|
|
|
Likewise, the two sockets created by
|
|
|
|
.BR socketpair (2)
|
|
|
|
are unnamed.
|
2012-04-17 10:56:21 +00:00
|
|
|
When the address of an unnamed socket is returned,
|
2008-08-08 16:41:48 +00:00
|
|
|
its length is
|
|
|
|
.IR "sizeof(sa_family_t)" ,
|
|
|
|
and
|
|
|
|
.I sun_path
|
|
|
|
should not be inspected.
|
|
|
|
.\" There is quite some variation across implementations: FreeBSD
|
|
|
|
.\" says the length is 16 bytes, HP-UX 11 says it's zero bytes.
|
|
|
|
.IP *
|
|
|
|
.IR abstract :
|
2012-04-17 10:56:21 +00:00
|
|
|
an abstract socket address is distinguished (from a pathname socket)
|
|
|
|
by the fact that
|
2008-08-08 16:41:48 +00:00
|
|
|
.IR sun_path[0]
|
locale.1, memusage.1, pldd.1, _syscall.2, add_key.2, bind.2, bpf.2, chown.2, clone.2, copy_file_range.2, eventfd.2, execve.2, futex.2, getdents.2, getrlimit.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, listxattr.2, lseek.2, membarrier.2, memfd_create.2, mmap.2, mprotect.2, msgop.2, open_by_handle_at.2, perf_event_open.2, pipe.2, readdir.2, readlink.2, readv.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, select.2, select_tut.2, sendmmsg.2, setns.2, signalfd.2, spu_run.2, stat.2, sysctl.2, tee.2, timer_create.2, timerfd_create.2, truncate.2, uname.2, unshare.2, userfaultfd.2, ustat.2, wait.2, CPU_SET.3, __ppc_get_timebase.3, argz_add.3, asprintf.3, backtrace.3, basename.3, bswap.3, bzero.3, cacos.3, cacosh.3, catan.3, catanh.3, catgets.3, clock_getcpuclockid.3, confstr.3, ctime.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, fgetws.3, fmemopen.3, fopencookie.3, fputws.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrouplist.3, getifaddrs.3, getline.3, getlogin.3, getopt.3, getpass.3, getprotoent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, index.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, iswblank.3, iswspace.3, makecontext.3, mallinfo.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbrtowc.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mcheck.3, memchr.3, mq_getattr.3, mq_notify.3, newlocale.3, nl_langinfo.3, offsetof.3, perror.3, posix_spawn.3, printf.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, qsort.3, rand.3, readdir.3, regex.3, rpmatch.3, rtime.3, scanf.3, sem_wait.3, setaliasent.3, setbuf.3, stpcpy.3, stpncpy.3, strcat.3, strchr.3, strcpy.3, strdup.3, strerror.3, strfromd.3, strftime.3, strlen.3, strnlen.3, strsep.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, termios.3, tsearch.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscat.3, wcscpy.3, wcslen.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcsrtombs.3, wcsstr.3, wcstok.3, wcstombs.3, wcwidth.3, wprintf.3, console_codes.4, dsp56k.4, full.4, initrd.4, loop.4, vcs.4, charmap.5, core.5, elf.5, locale.5, proc.5, repertoiremap.5, sysfs.5, termcap.5, aio.7, bpf-helpers.7, cgroups.7, charsets.7, complex.7, fanotify.7, feature_test_macros.7, inotify.7, locale.7, man-pages.7, man.7, pkeys.7, pthreads.7, rtld-audit.7, sock_diag.7, unix.7, user_namespaces.7, utf-8.7: Use '\e' rather than '\\' to get a backslash
Quoting Branden:
*roff escape sequences may sometimes look like C escapes, but that
is misleading. *roff is in part a macro language and that means
recursive expansion to arbitrary depths.
You can get away with "\\" in a context where no macro expansion
is taking place, but try to spell a literal backslash this way in
the argument to a macro and you will likely be unhappy with
results.
Try viewing the attached file with "man -l".
"\e" is the preferred and portable way to get a portable "escape
literal" going back to CSTR #54, the original Bell Labs troff
paper.
groff(7) discusses the issue:
\\ reduces to a single backslash; useful to delay its
interpretation as escape character in copy mode. For a
printable backslash, use \e, or even better \[rs], to be
independent from the current escape character.
As of groff 1.22.4, groff_man(7) does as well:
\e Widely used in man pages to represent a backslash output
glyph. It works reliably as long as the .ec request is
not used, which should never happen in man pages, and it
is slightly more portable than the more exact ‘\(rs’
(“reverse solidus”) escape sequence.
People not concerned with portability to extremely old troffs should
probably just use \(rs (or \[rs]), as it means "the backslash
glyph", not "the glyph corresponding to whatever the current escape
character is".
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-27 11:57:17 +00:00
|
|
|
is a null byte (\(aq\e0\(aq).
|
2010-10-10 04:59:41 +00:00
|
|
|
The socket's address in this namespace is given by the additional
|
|
|
|
bytes in
|
|
|
|
.IR sun_path
|
|
|
|
that are covered by the specified length of the address structure.
|
2008-08-08 16:41:48 +00:00
|
|
|
(Null bytes in the name have no special significance.)
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
The name has no connection with filesystem pathnames.
|
2012-04-17 10:56:21 +00:00
|
|
|
When the address of an abstract socket is returned,
|
2010-10-10 04:59:41 +00:00
|
|
|
the returned
|
|
|
|
.I addrlen
|
|
|
|
is greater than
|
|
|
|
.IR "sizeof(sa_family_t)"
|
|
|
|
(i.e., greater than 2), and the name of the socket is contained in
|
|
|
|
the first
|
|
|
|
.IR "(addrlen \- sizeof(sa_family_t))"
|
|
|
|
bytes of
|
|
|
|
.IR sun_path .
|
2012-04-17 10:56:21 +00:00
|
|
|
.SS Pathname sockets
|
|
|
|
When binding a socket to a pathname, a few rules should be observed
|
|
|
|
for maximum portability and ease of coding:
|
|
|
|
.IP * 3
|
|
|
|
The pathname in
|
|
|
|
.I sun_path
|
|
|
|
should be null-terminated.
|
|
|
|
.IP *
|
|
|
|
The length of the pathname, including the terminating null byte,
|
|
|
|
should not exceed the size of
|
|
|
|
.IR sun_path .
|
|
|
|
.IP *
|
|
|
|
The
|
|
|
|
.I addrlen
|
|
|
|
argument that describes the enclosing
|
|
|
|
.I sockaddr_un
|
|
|
|
structure should have a value of at least:
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2012-04-17 10:56:21 +00:00
|
|
|
.nf
|
|
|
|
offsetof(struct sockaddr_un, sun_path)+strlen(addr.sun_path)+1
|
|
|
|
.fi
|
|
|
|
.IP
|
2014-10-15 09:17:46 +00:00
|
|
|
or, more simply,
|
2012-04-17 10:56:21 +00:00
|
|
|
.I addrlen
|
|
|
|
can be specified as
|
|
|
|
.IR "sizeof(struct sockaddr_un)" .
|
|
|
|
.PP
|
|
|
|
There is some variation in how implementations handle UNIX domain
|
|
|
|
socket addresses that do not follow the above rules.
|
|
|
|
For example, some (but not all) implementations
|
|
|
|
.\" Linux does this, including for the case where the supplied path
|
|
|
|
.\" is 108 bytes
|
|
|
|
append a null terminator if none is present in the supplied
|
|
|
|
.IR sun_path .
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
When coding portable applications,
|
|
|
|
keep in mind that some implementations
|
|
|
|
.\" HP-UX
|
|
|
|
have
|
|
|
|
.I sun_path
|
|
|
|
as short as 92 bytes.
|
|
|
|
.\" Modern BSDs generally have 104, Tru64 and AIX have 104,
|
|
|
|
.\" Solaris and Irix have 108
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
Various system calls
|
|
|
|
.RB ( accept (2),
|
|
|
|
.BR recvfrom (2),
|
|
|
|
.BR getsockname (2),
|
|
|
|
.BR getpeername (2))
|
|
|
|
return socket address structures.
|
|
|
|
When applied to UNIX domain sockets, the value-result
|
|
|
|
.I addrlen
|
|
|
|
argument supplied to the call should be initialized as above.
|
|
|
|
Upon return, the argument is set to indicate the
|
|
|
|
.I actual
|
|
|
|
size of the address structure.
|
|
|
|
The caller should check the value returned in this argument:
|
|
|
|
if the output value exceeds the input value,
|
|
|
|
then there is no guarantee that a null terminator is present in
|
|
|
|
.IR sun_path .
|
|
|
|
(See BUGS.)
|
2016-06-20 09:14:27 +00:00
|
|
|
.\"
|
|
|
|
.SS Pathname socket ownership and permissions
|
|
|
|
In the Linux implementation,
|
|
|
|
pathname sockets honor the permissions of the directory they are in.
|
capget.2, fanotify_init.2, fcntl.2, ioctl_tty.2, madvise.2, mbind.2, prctl.2, sched_setaffinity.2, hash.3, isgreater.3, posix_fallocate.3, sigvec.3, full.4, sd.4, wavelan.4, core.5, host.conf.5, epoll.7, signal.7, unix.7, user_namespaces.7: wfix (will fail --> fail/fails)
Reported-by: Pedro Alves <palves@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-10-20 10:36:42 +00:00
|
|
|
Creation of a new socket fails if the process does not have write and
|
2016-06-20 09:14:27 +00:00
|
|
|
search (execute) permission on the directory in which the socket is created.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-20 09:14:27 +00:00
|
|
|
On Linux,
|
|
|
|
connecting to a stream socket object requires write permission on that socket;
|
|
|
|
sending a datagram to a datagram socket likewise
|
|
|
|
requires write permission on that socket.
|
|
|
|
POSIX does not make any statement about the effect of the permissions
|
2016-06-20 12:54:52 +00:00
|
|
|
on a socket file, and on some systems (e.g., older BSDs),
|
2016-06-20 09:14:27 +00:00
|
|
|
the socket permissions are ignored.
|
|
|
|
Portable programs should not rely on
|
|
|
|
this feature for security.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-20 09:14:27 +00:00
|
|
|
When creating a new socket, the owner and group of the socket file
|
|
|
|
are set according to the usual rules.
|
|
|
|
The socket file has all permissions enabled,
|
|
|
|
other than those that are turned off by the process
|
|
|
|
.BR umask (2).
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-20 09:14:27 +00:00
|
|
|
The owner, group, and permissions of a pathname socket can be changed (using
|
|
|
|
.BR chown (2)
|
|
|
|
and
|
|
|
|
.BR chmod (2)).
|
|
|
|
.\" However, fchown() and fchmod() do not seem to have an effect
|
|
|
|
.\"
|
2016-06-20 09:17:04 +00:00
|
|
|
.SS Abstract sockets
|
2016-06-20 09:24:11 +00:00
|
|
|
Socket permissions have no meaning for abstract sockets:
|
|
|
|
the process
|
|
|
|
.BR umask (2)
|
|
|
|
has no effect when binding an abstract socket,
|
|
|
|
and changing the ownership and permissions of the object (via
|
|
|
|
.BR fchown (2)
|
|
|
|
and
|
|
|
|
.BR fchmod (2))
|
|
|
|
has no effect on the accessibility of the socket.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-20 09:17:04 +00:00
|
|
|
Abstract sockets automatically disappear when all open references
|
|
|
|
to the socket are closed.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-20 09:17:04 +00:00
|
|
|
The abstract socket namespace is a nonportable Linux extension.
|
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Socket options
|
2014-11-08 05:13:13 +00:00
|
|
|
For historical reasons, these socket options are specified with a
|
2008-08-08 16:41:48 +00:00
|
|
|
.B SOL_SOCKET
|
|
|
|
type even though they are
|
2008-08-08 16:47:53 +00:00
|
|
|
.B AF_UNIX
|
2008-08-08 16:41:48 +00:00
|
|
|
specific.
|
|
|
|
They can be set with
|
|
|
|
.BR setsockopt (2)
|
|
|
|
and read with
|
|
|
|
.BR getsockopt (2)
|
|
|
|
by specifying
|
|
|
|
.B SOL_SOCKET
|
|
|
|
as the socket family.
|
|
|
|
.TP
|
|
|
|
.B SO_PASSCRED
|
2018-12-23 18:02:41 +00:00
|
|
|
Enabling this socket option causes receipt of the credentials of
|
2018-12-23 17:55:33 +00:00
|
|
|
the sending process in an
|
|
|
|
.B SCM_CREDENTIALS ancillary
|
2018-12-23 18:02:41 +00:00
|
|
|
message in each subsequently received message.
|
2018-12-23 17:55:33 +00:00
|
|
|
The returned credentials are those specified by the sender using
|
|
|
|
.BR SCM_CREDENTIALS ,
|
|
|
|
or a default that includes the sender's PID, real user ID, and real group ID,
|
|
|
|
if the sender did not specify
|
|
|
|
.B SCM_CREDENTIALS
|
|
|
|
ancillary data.
|
2018-12-23 17:11:54 +00:00
|
|
|
.IP
|
|
|
|
When this option is set and the socket is not yet connected,
|
2008-08-08 16:41:48 +00:00
|
|
|
a unique name in the abstract namespace will be generated automatically.
|
2018-12-23 17:10:25 +00:00
|
|
|
.IP
|
|
|
|
The value given as an argument to
|
|
|
|
.BR setsockopt (2)
|
|
|
|
and returned as the result of
|
|
|
|
.BR getsockopt (2)
|
|
|
|
is an integer boolean flag.
|
2018-07-26 08:40:48 +00:00
|
|
|
.TP
|
|
|
|
.B SO_PASSSEC
|
2018-07-26 08:49:02 +00:00
|
|
|
Enables receiving of the SELinux security label of the peer socket
|
|
|
|
in an ancillary message of type
|
|
|
|
.BR SCM_SECURITY
|
|
|
|
(see below).
|
2018-12-23 17:10:25 +00:00
|
|
|
.IP
|
|
|
|
The value given as an argument to
|
|
|
|
.BR setsockopt (2)
|
|
|
|
and returned as the result of
|
|
|
|
.BR getsockopt (2)
|
|
|
|
is an integer boolean flag.
|
|
|
|
.IP
|
|
|
|
The
|
|
|
|
.B SO_PASSSEC
|
|
|
|
option is supported for UNIX domain datagram sockets
|
2018-07-26 08:40:48 +00:00
|
|
|
.\" commit 877ce7c1b3afd69a9b1caeb1b9964c992641f52a
|
|
|
|
since Linux 2.6.18;
|
|
|
|
support for UNIX domain stream sockets was added
|
|
|
|
.\" commit 37a9a8df8ce9de6ea73349c9ac8bdf6ba4ec4f70
|
|
|
|
in Linux 4.2.
|
2018-07-28 09:04:26 +00:00
|
|
|
.TP
|
|
|
|
.BR SO_PEEK_OFF
|
|
|
|
See
|
|
|
|
.BR socket (7).
|
2018-07-28 09:08:03 +00:00
|
|
|
.TP
|
|
|
|
.B SO_PEERCRED
|
2018-12-23 17:24:06 +00:00
|
|
|
This read-only socket option returns the
|
|
|
|
credentials of the peer process connected to this socket.
|
2018-07-28 09:08:03 +00:00
|
|
|
The returned credentials are those that were in effect at the time
|
|
|
|
of the call to
|
|
|
|
.BR connect (2)
|
|
|
|
or
|
|
|
|
.BR socketpair (2).
|
2018-12-23 17:24:06 +00:00
|
|
|
.IP
|
|
|
|
The argument to
|
|
|
|
.BR getsockopt (2)
|
|
|
|
is a pointer to a
|
2018-07-28 09:08:03 +00:00
|
|
|
.I ucred
|
|
|
|
structure; define the
|
|
|
|
.B _GNU_SOURCE
|
|
|
|
feature test macro to obtain the definition of that structure from
|
|
|
|
.IR <sys/socket.h> .
|
2018-12-23 17:24:06 +00:00
|
|
|
.IP
|
|
|
|
The use of this option is possible only for connected
|
|
|
|
.B AF_UNIX
|
|
|
|
stream sockets and for
|
|
|
|
.B AF_UNIX
|
|
|
|
stream and datagram socket pairs created using
|
|
|
|
.BR socketpair (2).
|
2018-07-26 08:40:48 +00:00
|
|
|
.\"
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Autobind feature
|
2010-10-10 05:47:14 +00:00
|
|
|
If a
|
Changes, clone.2, mount.2, nanosleep.2, sigaltstack.2, statfs.2, timer_settime.2, ctime.3, fmemopen.3, nl_langinfo.3, posix_memalign.3, pthread_attr_init.3, pthread_setaffinity_np.3, pthread_setschedprio.3, pthread_testcancel.3, setjmp.3, sigwait.3, tty_ioctl.4, epoll.7, posixoptions.7, unix.7: Add section number to references to functions documented in other pages
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-11-01 07:07:28 +00:00
|
|
|
.BR bind (2)
|
2010-10-10 05:47:14 +00:00
|
|
|
call specifies
|
|
|
|
.I addrlen
|
|
|
|
as
|
|
|
|
.IR sizeof(sa_family_t) ,
|
2014-01-01 03:17:09 +00:00
|
|
|
.\" i.e., sizeof(short)
|
2010-10-10 05:47:14 +00:00
|
|
|
or the
|
|
|
|
.BR SO_PASSCRED
|
|
|
|
socket option was specified for a socket that was
|
|
|
|
not explicitly bound to an address,
|
|
|
|
then the socket is autobound to an abstract address.
|
|
|
|
The address consists of a null byte
|
|
|
|
followed by 5 bytes in the character set
|
ctime.3, drand48.3, fmtmsg.3, getnameinfo.3, gsignal.3, strftime.3, strptime.3, cciss.4, console_codes.4, sd.4, sk98lin.4, st.4, proc.5, charsets.7, cpuset.7, pty.7, suffixes.7, udplite.7, unix.7: Use en-dash for ranges
Based on a patch by Bjarni Ingi Gislason.
Reported-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-19 20:01:55 +00:00
|
|
|
.IR [0\-9a\-f] .
|
2012-04-15 21:05:00 +00:00
|
|
|
Thus, there is a limit of 2^20 autobind addresses.
|
|
|
|
(From Linux 2.1.15, when the autobind feature was added,
|
|
|
|
8 bytes were used, and the limit was thus 2^32 autobind addresses.
|
|
|
|
The change to 5 bytes came in Linux 2.3.15.)
|
2008-12-01 15:18:35 +00:00
|
|
|
.SS Sockets API
|
2008-08-08 16:41:48 +00:00
|
|
|
The following paragraphs describe domain-specific details and
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
unsupported features of the sockets API for UNIX domain sockets on Linux.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
UNIX domain sockets do not support the transmission of
|
2008-08-08 16:41:48 +00:00
|
|
|
out-of-band data (the
|
|
|
|
.B MSG_OOB
|
|
|
|
flag for
|
|
|
|
.BR send (2)
|
|
|
|
and
|
|
|
|
.BR recv (2)).
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2008-08-08 16:41:48 +00:00
|
|
|
The
|
|
|
|
.BR send (2)
|
|
|
|
.B MSG_MORE
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
flag is not supported by UNIX domain sockets.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2017-01-15 20:57:12 +00:00
|
|
|
Before Linux 3.4,
|
|
|
|
.\" commit 9f6f9af7694ede6314bed281eec74d588ba9474f
|
|
|
|
the use of
|
2008-12-01 16:25:44 +00:00
|
|
|
.B MSG_TRUNC
|
|
|
|
in the
|
|
|
|
.I flags
|
|
|
|
argument of
|
|
|
|
.BR recv (2)
|
2017-01-15 20:57:12 +00:00
|
|
|
was not supported by UNIX domain sockets.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2008-08-08 16:41:48 +00:00
|
|
|
The
|
|
|
|
.B SO_SNDBUF
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
socket option does have an effect for UNIX domain sockets, but the
|
2008-08-08 16:41:48 +00:00
|
|
|
.B SO_RCVBUF
|
|
|
|
option does not.
|
|
|
|
For datagram sockets, the
|
|
|
|
.B SO_SNDBUF
|
|
|
|
value imposes an upper limit on the size of outgoing datagrams.
|
|
|
|
This limit is calculated as the doubled (see
|
|
|
|
.BR socket (7))
|
|
|
|
option value less 32 bytes used for overhead.
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS Ancillary messages
|
2008-08-08 16:41:48 +00:00
|
|
|
Ancillary data is sent and received using
|
|
|
|
.BR sendmsg (2)
|
|
|
|
and
|
|
|
|
.BR recvmsg (2).
|
2018-07-08 19:29:13 +00:00
|
|
|
For historical reasons, the ancillary message types listed below
|
2008-08-08 16:41:48 +00:00
|
|
|
are specified with a
|
|
|
|
.B SOL_SOCKET
|
|
|
|
type even though they are
|
2008-08-08 16:47:53 +00:00
|
|
|
.B AF_UNIX
|
2008-08-08 16:41:48 +00:00
|
|
|
specific.
|
2018-07-08 19:29:13 +00:00
|
|
|
To send them, set the
|
2008-08-08 16:41:48 +00:00
|
|
|
.I cmsg_level
|
|
|
|
field of the struct
|
|
|
|
.I cmsghdr
|
|
|
|
to
|
|
|
|
.B SOL_SOCKET
|
|
|
|
and the
|
|
|
|
.I cmsg_type
|
|
|
|
field to the type.
|
2018-07-08 19:29:13 +00:00
|
|
|
For more information, see
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR cmsg (3).
|
|
|
|
.TP
|
|
|
|
.B SCM_RIGHTS
|
|
|
|
Send or receive a set of open file descriptors from another process.
|
|
|
|
The data portion contains an integer array of the file descriptors.
|
2018-07-15 07:50:30 +00:00
|
|
|
.IP
|
2018-07-08 08:57:27 +00:00
|
|
|
Commonly, this operation is referred to as "passing a file descriptor"
|
|
|
|
to another process.
|
|
|
|
However, more accurately,
|
|
|
|
what is being passed is a reference to an open file description (see
|
|
|
|
.BR open (2)),
|
|
|
|
and in the receiving process it is likely that a different
|
|
|
|
file descriptor number will be used.
|
|
|
|
Semantically, this operation is equivalent to duplicating
|
|
|
|
.RB ( dup (2))
|
|
|
|
a file descriptor into the file descriptor table of another process.
|
2018-07-08 08:30:32 +00:00
|
|
|
.IP
|
2018-07-15 07:53:35 +00:00
|
|
|
If the buffer used to receive the ancillary data containing
|
|
|
|
file descriptors is too small (or is absent),
|
|
|
|
then the ancillary data is truncated (or discarded)
|
|
|
|
and the excess file descriptors are automatically closed
|
|
|
|
in the receiving process.
|
|
|
|
.IP
|
2018-07-08 08:30:32 +00:00
|
|
|
The kernel constant
|
|
|
|
.BR SCM_MAX_FD
|
|
|
|
defines a limit on the number of file descriptors in the array.
|
2018-07-26 09:46:22 +00:00
|
|
|
Attempting to send an array larger than this limit causes
|
2018-07-08 08:30:32 +00:00
|
|
|
.BR sendmsg (2)
|
|
|
|
to fail with the error
|
|
|
|
.BR EINVAL .
|
|
|
|
.BR SCM_MAX_FD
|
|
|
|
has the value 253
|
|
|
|
(or 255 in kernels
|
|
|
|
.\" commit bba14de98753cb6599a2dae0e520714b2153522d
|
|
|
|
before 2.6.38).
|
2008-08-08 16:41:48 +00:00
|
|
|
.TP
|
|
|
|
.B SCM_CREDENTIALS
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
Send or receive UNIX credentials.
|
2008-08-08 16:41:48 +00:00
|
|
|
This can be used for authentication.
|
|
|
|
The credentials are passed as a
|
|
|
|
.I struct ucred
|
|
|
|
ancillary message.
|
2008-09-01 14:57:49 +00:00
|
|
|
Thus structure is defined in
|
|
|
|
.I <sys/socket.h>
|
|
|
|
as follows:
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2008-08-08 16:41:48 +00:00
|
|
|
.in +4n
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EX
|
2008-08-08 16:41:48 +00:00
|
|
|
struct ucred {
|
2018-07-15 07:57:11 +00:00
|
|
|
pid_t pid; /* Process ID of the sending process */
|
|
|
|
uid_t uid; /* User ID of the sending process */
|
|
|
|
gid_t gid; /* Group ID of the sending process */
|
2008-08-08 16:41:48 +00:00
|
|
|
};
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EE
|
2008-08-08 16:41:48 +00:00
|
|
|
.in
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2008-09-01 14:57:49 +00:00
|
|
|
Since glibc 2.8, the
|
2008-12-01 12:20:45 +00:00
|
|
|
.B _GNU_SOURCE
|
2010-09-10 04:33:31 +00:00
|
|
|
feature test macro must be defined (before including
|
|
|
|
.I any
|
|
|
|
header files) in order to obtain the definition
|
2008-09-01 14:57:49 +00:00
|
|
|
of this structure.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2008-08-08 16:41:48 +00:00
|
|
|
The credentials which the sender specifies are checked by the kernel.
|
2018-07-08 08:21:43 +00:00
|
|
|
A privileged process is allowed to specify values that do not match its own.
|
2008-08-08 16:41:48 +00:00
|
|
|
The sender must specify its own process ID (unless it has the capability
|
|
|
|
.BR CAP_SYS_ADMIN ),
|
2017-03-18 19:42:58 +00:00
|
|
|
its real user ID, effective user ID, or saved set-user-ID (unless it has
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR CAP_SETUID ),
|
2017-03-18 19:42:58 +00:00
|
|
|
and its real group ID, effective group ID, or saved set-group-ID
|
2008-08-08 16:41:48 +00:00
|
|
|
(unless it has
|
|
|
|
.BR CAP_SETGID ).
|
2018-07-08 08:20:32 +00:00
|
|
|
.IP
|
2008-08-08 16:41:48 +00:00
|
|
|
To receive a
|
|
|
|
.I struct ucred
|
2018-07-08 08:20:52 +00:00
|
|
|
message, the
|
2008-08-08 16:41:48 +00:00
|
|
|
.B SO_PASSCRED
|
|
|
|
option must be enabled on the socket.
|
2018-07-26 08:49:02 +00:00
|
|
|
.TP
|
|
|
|
.B SCM_SECURITY
|
|
|
|
Receive the SELinux security context (the security label)
|
|
|
|
of the peer socket.
|
|
|
|
The received ancillary data is a null-terminated string containing
|
|
|
|
the security context.
|
|
|
|
The receiver should allocate at least
|
|
|
|
.BR NAME_MAX
|
|
|
|
bytes in the data portion of the ancillary message for this data.
|
|
|
|
.IP
|
|
|
|
To receive the security context, the
|
|
|
|
.B SO_PASSSEC
|
|
|
|
option must be enabled on the socket (see above).
|
2018-07-08 09:00:23 +00:00
|
|
|
.PP
|
2018-07-08 20:06:51 +00:00
|
|
|
When sending ancillary data with
|
|
|
|
.BR sendmsg (2),
|
|
|
|
only one item of each of the above types may be included in the sent message.
|
|
|
|
.PP
|
2018-07-15 08:30:11 +00:00
|
|
|
At least one byte of real data should be sent when sending ancillary data.
|
|
|
|
On Linux, this is required to successfully send ancillary data over
|
|
|
|
a UNIX domain stream socket.
|
|
|
|
When sending ancillary data over a UNIX domain datagram socket,
|
|
|
|
it is not necessary on Linux to send any accompanying real data.
|
|
|
|
However, portable applications should also include at least one byte
|
|
|
|
of real data when sending ancillary data over a datagram socket.
|
|
|
|
.PP
|
2018-07-17 07:39:56 +00:00
|
|
|
When receiving from a stream socket,
|
|
|
|
ancillary data forms a kind of barrier for the received data.
|
|
|
|
For example, suppose that the sender transmits as follows:
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
.PD 0
|
|
|
|
.IP 1. 3
|
|
|
|
.BR sendmsg (2)
|
|
|
|
of four bytes, with no ancillary data.
|
|
|
|
.IP 2.
|
|
|
|
.BR sendmsg (2)
|
|
|
|
of one byte, with ancillary data.
|
|
|
|
.IP 3.
|
|
|
|
.BR sendmsg (2)
|
|
|
|
of four bytes, with no ancillary data.
|
|
|
|
.PD
|
|
|
|
.RE
|
|
|
|
.PP
|
|
|
|
Suppose that the receiver now performs
|
|
|
|
.BR recvmsg (2)
|
|
|
|
calls each with a buffer size of 20 bytes.
|
|
|
|
The first call will receive five bytes of data,
|
|
|
|
along with the ancillary data sent by the second
|
|
|
|
.BR sendmsg (2)
|
|
|
|
call.
|
|
|
|
The next call will receive the remaining five bytes of data.
|
|
|
|
.PP
|
2018-07-15 08:22:58 +00:00
|
|
|
If the space allocated for receiving incoming ancillary data is too small
|
2018-07-08 09:00:23 +00:00
|
|
|
then the ancillary data is truncated to the number of headers
|
|
|
|
that will fit in the supplied buffer (or, in the case of an
|
|
|
|
.BR SCM_RIGHTS
|
|
|
|
file descriptor list, the list of file descriptors may be truncated).
|
2018-07-15 08:22:58 +00:00
|
|
|
If no buffer is provided for incoming ancillary data (i.e., the
|
|
|
|
.I msg_control
|
|
|
|
field of the
|
|
|
|
.I msghdr
|
|
|
|
structure supplied to
|
|
|
|
.BR recvmsg (2)
|
|
|
|
is NULL),
|
|
|
|
then the incoming ancillary data is discarded.
|
|
|
|
In both of these cases, the
|
2018-07-08 09:00:23 +00:00
|
|
|
.BR MSG_CTRUNC
|
|
|
|
flag will be set in the
|
|
|
|
.I msg.msg_flags
|
|
|
|
value returned by
|
|
|
|
.BR recvmsg (2).
|
|
|
|
.\"
|
2010-09-10 04:00:39 +00:00
|
|
|
.SS Ioctls
|
|
|
|
The following
|
|
|
|
.BR ioctl (2)
|
|
|
|
calls return information in
|
|
|
|
.IR value .
|
|
|
|
The correct syntax is:
|
|
|
|
.PP
|
|
|
|
.RS
|
|
|
|
.nf
|
|
|
|
.BI int " value";
|
2011-09-08 16:20:44 +00:00
|
|
|
.IB error " = ioctl(" unix_socket ", " ioctl_type ", &" value ");"
|
2010-09-10 04:00:39 +00:00
|
|
|
.fi
|
|
|
|
.RE
|
|
|
|
.PP
|
|
|
|
.I ioctl_type
|
|
|
|
can be:
|
|
|
|
.TP
|
|
|
|
.B SIOCINQ
|
2014-10-18 15:36:00 +00:00
|
|
|
For
|
|
|
|
.B SOCK_STREAM
|
2018-07-08 19:46:40 +00:00
|
|
|
sockets, this call returns the number of unread bytes in the receive buffer.
|
2010-09-10 04:00:39 +00:00
|
|
|
The socket must not be in LISTEN state, otherwise an error
|
|
|
|
.RB ( EINVAL )
|
|
|
|
is returned.
|
|
|
|
.B SIOCINQ
|
|
|
|
is defined in
|
|
|
|
.IR <linux/sockios.h> .
|
adjtimex.2, bind.2, cacheflush.2, clone.2, fallocate.2, fanotify_init.2, fanotify_mark.2, flock.2, futex.2, getdents.2, getpriority.2, getrlimit.2, gettid.2, gettimeofday.2, ioprio_set.2, kexec_load.2, migrate_pages.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, msgop.2, nfsservctl.2, perf_event_open.2, pread.2, ptrace.2, recvmmsg.2, rename.2, restart_syscall.2, sched_setattr.2, send.2, shmop.2, shutdown.2, sigaction.2, signalfd.2, syscalls.2, timer_create.2, timerfd_create.2, tkill.2, vmsplice.2, wait.2, aio_init.3, confstr.3, exit.3, fmemopen.3, fopen.3, getaddrinfo.3, getauxval.3, getspnam.3, isalpha.3, isatty.3, mallinfo.3, malloc.3, mallopt.3, psignal.3, pthread_attr_setinheritsched.3, qecvt.3, queue.3, rtnetlink.3, strerror.3, strftime.3, toupper.3, towlower.3, towupper.3, initrd.4, locale.5, proc.5, bootparam.7, capabilities.7, ddp.7, fanotify.7, icmp.7, inotify.7, ip.7, ipv6.7, netdevice.7, netlink.7, path_resolution.7, rtld-audit.7, rtnetlink.7, sched.7, signal.7, socket.7, svipc.7, tcp.7, unix.7, ld.so.8: srcfix: Update FIXMEs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2014-08-21 21:47:44 +00:00
|
|
|
.\" FIXME . http://sources.redhat.com/bugzilla/show_bug.cgi?id=12002,
|
2010-09-10 04:00:39 +00:00
|
|
|
.\" filed 2010-09-10, may cause SIOCINQ to be defined in glibc headers
|
|
|
|
Alternatively,
|
|
|
|
you can use the synonymous
|
|
|
|
.BR FIONREAD ,
|
|
|
|
defined in
|
|
|
|
.IR <sys/ioctl.h> .
|
2010-09-10 04:01:31 +00:00
|
|
|
.\" SIOCOUTQ also has an effect for UNIX domain sockets, but not
|
2010-09-10 04:00:39 +00:00
|
|
|
.\" quite what userland might expect. It seems to return the number
|
|
|
|
.\" of bytes allocated for buffers containing pending output.
|
|
|
|
.\" That number is normally larger than the number of bytes of pending
|
|
|
|
.\" output. Since this info is, from userland's point of view, imprecise,
|
|
|
|
.\" and it may well change, probably best not to document this now.
|
2014-10-18 15:36:00 +00:00
|
|
|
For
|
|
|
|
.B SOCK_DGRAM
|
2018-07-08 19:46:40 +00:00
|
|
|
sockets,
|
2014-10-18 15:36:00 +00:00
|
|
|
the returned value is the same as
|
2018-07-08 19:46:40 +00:00
|
|
|
for Internet domain datagram sockets;
|
2014-10-18 15:36:00 +00:00
|
|
|
see
|
|
|
|
.BR udp (7).
|
2008-08-08 16:41:48 +00:00
|
|
|
.SH ERRORS
|
|
|
|
.TP
|
|
|
|
.B EADDRINUSE
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
The specified local address is already in use or the filesystem socket
|
2008-08-08 16:41:48 +00:00
|
|
|
object already exists.
|
|
|
|
.TP
|
unix.7: ERRORS: add EBADF for sending closed file descriptor with SCM_RIGHTS
As noted by Rusty Russell:
I was really surprised that sendmsg() returned EBADF on a valid fd;
turns out I was using sendmsg with SCM_RIGHTS to send a closed fd,
which gives EBADF (see test program below).
But this is only obliquely referenced in unix(7):
SCM_RIGHTS
Send or receive a set of open file descriptors
from another process. The data portion contains
an integer array of the file descriptors. The
passed file descriptors behave as though they have
been created with dup(2).
EBADF is not mentioned in the unix(7) ERRORS (it's mentioned in
dup(2)).
int fdpass_send(int sockout, int fd)
{
/* From the cmsg(3) manpage: */
struct msghdr msg = { 0 };
struct cmsghdr *cmsg;
struct iovec iov;
char c = 0;
union { /* Ancillary data buffer, wrapped in a union
in order to ensure it is suitably aligned */
char buf[CMSG_SPACE(sizeof(fd))];
struct cmsghdr align;
} u;
msg.msg_control = u.buf;
msg.msg_controllen = sizeof(u.buf);
memset(&u, 0, sizeof(u));
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
/* Keith Packard reports that 0-length sends don't work, so we
* always send 1 byte. */
iov.iov_base = &c;
iov.iov_len = 1;
return sendmsg(sockout, &msg, 0);
}
int fdpass_recv(int sockin)
{
/* From the cmsg(3) manpage: */
struct msghdr msg = { 0 };
struct cmsghdr *cmsg;
struct iovec iov;
int fd;
char c;
union { /* Ancillary data buffer, wrapped in a union
in order to ensure it is suitably aligned */
char buf[CMSG_SPACE(sizeof(fd))];
struct cmsghdr align;
} u;
msg.msg_control = u.buf;
msg.msg_controllen = sizeof(u.buf);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
iov.iov_base = &c;
iov.iov_len = 1;
if (recvmsg(sockin, &msg, 0) < 0)
return -1;
cmsg = CMSG_FIRSTHDR(&msg);
if (!cmsg
|| cmsg->cmsg_len != CMSG_LEN(sizeof(fd))
|| cmsg->cmsg_level != SOL_SOCKET
|| cmsg->cmsg_type != SCM_RIGHTS) {
errno = -EINVAL;
return -1;
}
memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
return fd;
}
static void child(int sockfd)
{
int newfd = fdpass_recv(sockfd);
assert(newfd < 0);
exit(0);
}
int main(void)
{
int sv[2];
int pid, ret;
assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
pid = fork();
if (pid == 0) {
close(sv[1]);
child(sv[0]);
}
close(sv[0]);
ret = fdpass_send(sv[1], sv[0]);
printf("fdpass of bad fd return %i (%s)\n", ret, strerror(errno));
return 0;
}
Reported-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 08:53:21 +00:00
|
|
|
.B EBADF
|
|
|
|
This error can occur for
|
|
|
|
.BR sendmsg (2)
|
|
|
|
when sending a file descriptor as ancillary data over
|
|
|
|
a UNIX domain socket (see the description of
|
|
|
|
.BR SCM_RIGHTS ,
|
|
|
|
above), and indicates that the file descriptor number that
|
2018-04-26 21:28:17 +00:00
|
|
|
is being sent is not valid (e.g., it is not an open file descriptor).
|
unix.7: ERRORS: add EBADF for sending closed file descriptor with SCM_RIGHTS
As noted by Rusty Russell:
I was really surprised that sendmsg() returned EBADF on a valid fd;
turns out I was using sendmsg with SCM_RIGHTS to send a closed fd,
which gives EBADF (see test program below).
But this is only obliquely referenced in unix(7):
SCM_RIGHTS
Send or receive a set of open file descriptors
from another process. The data portion contains
an integer array of the file descriptors. The
passed file descriptors behave as though they have
been created with dup(2).
EBADF is not mentioned in the unix(7) ERRORS (it's mentioned in
dup(2)).
int fdpass_send(int sockout, int fd)
{
/* From the cmsg(3) manpage: */
struct msghdr msg = { 0 };
struct cmsghdr *cmsg;
struct iovec iov;
char c = 0;
union { /* Ancillary data buffer, wrapped in a union
in order to ensure it is suitably aligned */
char buf[CMSG_SPACE(sizeof(fd))];
struct cmsghdr align;
} u;
msg.msg_control = u.buf;
msg.msg_controllen = sizeof(u.buf);
memset(&u, 0, sizeof(u));
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
cmsg->cmsg_len = CMSG_LEN(sizeof(fd));
memcpy(CMSG_DATA(cmsg), &fd, sizeof(fd));
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
/* Keith Packard reports that 0-length sends don't work, so we
* always send 1 byte. */
iov.iov_base = &c;
iov.iov_len = 1;
return sendmsg(sockout, &msg, 0);
}
int fdpass_recv(int sockin)
{
/* From the cmsg(3) manpage: */
struct msghdr msg = { 0 };
struct cmsghdr *cmsg;
struct iovec iov;
int fd;
char c;
union { /* Ancillary data buffer, wrapped in a union
in order to ensure it is suitably aligned */
char buf[CMSG_SPACE(sizeof(fd))];
struct cmsghdr align;
} u;
msg.msg_control = u.buf;
msg.msg_controllen = sizeof(u.buf);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
msg.msg_flags = 0;
iov.iov_base = &c;
iov.iov_len = 1;
if (recvmsg(sockin, &msg, 0) < 0)
return -1;
cmsg = CMSG_FIRSTHDR(&msg);
if (!cmsg
|| cmsg->cmsg_len != CMSG_LEN(sizeof(fd))
|| cmsg->cmsg_level != SOL_SOCKET
|| cmsg->cmsg_type != SCM_RIGHTS) {
errno = -EINVAL;
return -1;
}
memcpy(&fd, CMSG_DATA(cmsg), sizeof(fd));
return fd;
}
static void child(int sockfd)
{
int newfd = fdpass_recv(sockfd);
assert(newfd < 0);
exit(0);
}
int main(void)
{
int sv[2];
int pid, ret;
assert(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
pid = fork();
if (pid == 0) {
close(sv[1]);
child(sv[0]);
}
close(sv[0]);
ret = fdpass_send(sv[1], sv[0]);
printf("fdpass of bad fd return %i (%s)\n", ret, strerror(errno));
return 0;
}
Reported-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 08:53:21 +00:00
|
|
|
.TP
|
2008-08-08 16:41:48 +00:00
|
|
|
.B ECONNREFUSED
|
2010-11-15 05:26:41 +00:00
|
|
|
The remote address specified by
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR connect (2)
|
2010-11-15 05:26:41 +00:00
|
|
|
was not a listening socket.
|
2012-04-17 10:56:21 +00:00
|
|
|
This error can also occur if the target pathname is not a socket.
|
2008-08-08 16:41:48 +00:00
|
|
|
.TP
|
|
|
|
.B ECONNRESET
|
|
|
|
Remote socket was unexpectedly closed.
|
|
|
|
.TP
|
|
|
|
.B EFAULT
|
|
|
|
User memory address was not valid.
|
|
|
|
.TP
|
|
|
|
.B EINVAL
|
|
|
|
Invalid argument passed.
|
2010-11-15 05:26:41 +00:00
|
|
|
A common cause is that the value
|
2010-11-15 05:18:31 +00:00
|
|
|
.B AF_UNIX
|
2010-11-15 05:26:41 +00:00
|
|
|
was not specified in the
|
2008-08-08 16:41:48 +00:00
|
|
|
.I sun_type
|
2010-11-15 05:26:41 +00:00
|
|
|
field of passed addresses, or the socket was in an
|
2008-08-08 16:41:48 +00:00
|
|
|
invalid state for the applied operation.
|
|
|
|
.TP
|
|
|
|
.B EISCONN
|
|
|
|
.BR connect (2)
|
|
|
|
called on an already connected socket or a target address was
|
|
|
|
specified on a connected socket.
|
|
|
|
.TP
|
2010-11-15 05:29:21 +00:00
|
|
|
.B ENOENT
|
|
|
|
The pathname in the remote address specified to
|
2011-09-08 15:32:08 +00:00
|
|
|
.BR connect (2)
|
2010-11-15 05:29:21 +00:00
|
|
|
did not exist.
|
|
|
|
.TP
|
2008-08-08 16:41:48 +00:00
|
|
|
.B ENOMEM
|
|
|
|
Out of memory.
|
|
|
|
.TP
|
|
|
|
.B ENOTCONN
|
|
|
|
Socket operation needs a target address, but the socket is not connected.
|
|
|
|
.TP
|
|
|
|
.B EOPNOTSUPP
|
|
|
|
Stream operation called on non-stream oriented socket or tried to
|
|
|
|
use the out-of-band data option.
|
|
|
|
.TP
|
|
|
|
.B EPERM
|
|
|
|
The sender passed invalid credentials in the
|
|
|
|
.IR "struct ucred" .
|
|
|
|
.TP
|
|
|
|
.B EPIPE
|
|
|
|
Remote socket was closed on a stream socket.
|
|
|
|
If enabled, a
|
|
|
|
.B SIGPIPE
|
|
|
|
is sent as well.
|
|
|
|
This can be avoided by passing the
|
|
|
|
.B MSG_NOSIGNAL
|
|
|
|
flag to
|
2016-07-22 06:55:40 +00:00
|
|
|
.BR send (2)
|
2008-08-08 16:41:48 +00:00
|
|
|
or
|
2016-07-22 06:55:40 +00:00
|
|
|
.BR sendmsg (2).
|
2008-08-08 16:41:48 +00:00
|
|
|
.TP
|
|
|
|
.B EPROTONOSUPPORT
|
2010-11-15 05:29:39 +00:00
|
|
|
Passed protocol is not
|
|
|
|
.BR AF_UNIX .
|
2008-08-08 16:41:48 +00:00
|
|
|
.TP
|
|
|
|
.B EPROTOTYPE
|
|
|
|
Remote socket does not match the local socket type
|
|
|
|
.RB ( SOCK_DGRAM
|
2010-11-15 05:36:53 +00:00
|
|
|
versus
|
2016-12-16 10:30:16 +00:00
|
|
|
.BR SOCK_STREAM ).
|
2008-08-08 16:41:48 +00:00
|
|
|
.TP
|
|
|
|
.B ESOCKTNOSUPPORT
|
|
|
|
Unknown socket type.
|
2016-12-16 10:32:05 +00:00
|
|
|
.TP
|
|
|
|
.B ETOOMANYREFS
|
|
|
|
This error can occur for
|
|
|
|
.BR sendmsg (2)
|
2017-01-03 23:36:57 +00:00
|
|
|
when sending a file descriptor as ancillary data over
|
2016-12-16 10:32:05 +00:00
|
|
|
a UNIX domain socket (see the description of
|
|
|
|
.BR SCM_RIGHTS ,
|
|
|
|
above).
|
|
|
|
It occurs if the number of "in-flight" file descriptors exceeds the
|
|
|
|
.B RLIMIT_NOFILE
|
|
|
|
resource limit and the caller does not have the
|
|
|
|
.BR CAP_SYS_RESOURCE
|
|
|
|
capability.
|
|
|
|
An in-flight file descriptor is one that has been sent using
|
|
|
|
.BR sendmsg (2)
|
|
|
|
but has not yet been accepted in the recipient process using
|
|
|
|
.BR recvmsg (2).
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.IP
|
2016-12-17 09:31:40 +00:00
|
|
|
This error is diagnosed since mainline Linux 4.5
|
|
|
|
(and in some earlier kernel versions where the fix has been backported).
|
2016-12-16 10:32:05 +00:00
|
|
|
.\" commit 712f4aad406bb1ed67f3f98d04c044191f0ff593
|
|
|
|
In earlier kernel versions,
|
|
|
|
it was possible to place an unlimited number of file descriptors in flight,
|
|
|
|
by sending each file descriptor with
|
|
|
|
.BR sendmsg (2)
|
|
|
|
and then closing the file descriptor so that it was not accounted against the
|
|
|
|
.B RLIMIT_NOFILE
|
|
|
|
resource limit.
|
2008-08-08 16:41:48 +00:00
|
|
|
.PP
|
|
|
|
Other errors can be generated by the generic socket layer or
|
intro.1, time.1, access.2, acct.2, alloc_hugepages.2, bind.2, chdir.2, chmod.2, chown.2, chroot.2, clone.2, close.2, execve.2, fallocate.2, fcntl.2, getdents.2, getrusage.2, getxattr.2, init_module.2, inotify_add_watch.2, ioprio_set.2, kcmp.2, link.2, listxattr.2, lseek.2, madvise.2, mkdir.2, mknod.2, mmap.2, mount.2, move_pages.2, msgctl.2, nfsservctl.2, open.2, pivot_root.2, quotactl.2, read.2, readlink.2, removexattr.2, rename.2, rmdir.2, semctl.2, setfsgid.2, setfsuid.2, setresuid.2, setuid.2, setup.2, setxattr.2, shmctl.2, splice.2, spu_create.2, stat.2, statfs.2, swapon.2, symlink.2, sync.2, sync_file_range.2, sysfs.2, truncate.2, umount.2, unlink.2, unshare.2, ustat.2, utime.2, utimensat.2, write.2, btree.3, errno.3, fexecve.3, ftw.3, futimes.3, get_nprocs_conf.3, getcwd.3, getdirentries.3, getmntent.3, glob.3, mkfifo.3, mq_open.3, readdir.3, realpath.3, recno.3, remove.3, sem_open.3, shm_open.3, statvfs.3, sysconf.3, telldir.3, tmpfile.3, cciss.4, initrd.4, pts.4, sk98lin.4, vcs.4, core.5, filesystems.5, proc.5, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, feature_test_macros.7, fifo.7, hier.7, inotify.7, intro.7, mq_overview.7, path_resolution.7, pipe.7, sem_overview.7, shm_overview.7, spufs.7, symlink.7, unix.7, uri.7, sync.8: Global fix: s/file system/filesystem/
Notwithstanding 24d01c530c5a3f75217543d02bf6712395e5f90c,
"filesystem" is the form used by the great majority of man pages
outside the man-pages project and in a number of other sources,
so let's go with that.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-08-08 08:07:57 +00:00
|
|
|
by the filesystem while generating a filesystem socket object.
|
2008-08-08 16:41:48 +00:00
|
|
|
See the appropriate manual pages for more information.
|
|
|
|
.SH VERSIONS
|
|
|
|
.B SCM_CREDENTIALS
|
|
|
|
and the abstract namespace were introduced with Linux 2.2 and should not
|
|
|
|
be used in portable programs.
|
|
|
|
(Some BSD-derived systems also support credential passing,
|
|
|
|
but the implementation details differ.)
|
|
|
|
.SH NOTES
|
2016-06-17 16:51:38 +00:00
|
|
|
Binding to a socket with a filename creates a socket
|
|
|
|
in the filesystem that must be deleted by the caller when it is no
|
|
|
|
longer needed (using
|
|
|
|
.BR unlink (2)).
|
|
|
|
The usual UNIX close-behind semantics apply; the socket can be unlinked
|
|
|
|
at any time and will be finally removed from the filesystem when the last
|
|
|
|
reference to it is closed.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-17 16:51:38 +00:00
|
|
|
To pass file descriptors or credentials over a
|
2018-04-12 08:42:34 +00:00
|
|
|
.BR SOCK_STREAM
|
|
|
|
socket, you must
|
2016-06-17 16:51:38 +00:00
|
|
|
to send or receive at least one byte of nonancillary data in the same
|
|
|
|
.BR sendmsg (2)
|
|
|
|
or
|
|
|
|
.BR recvmsg (2)
|
|
|
|
call.
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2016-06-17 16:51:38 +00:00
|
|
|
UNIX domain stream sockets do not support the notion of out-of-band data.
|
|
|
|
.\"
|
2012-04-17 10:56:21 +00:00
|
|
|
.SH BUGS
|
|
|
|
When binding a socket to an address,
|
|
|
|
Linux is one of the implementations that appends a null terminator
|
|
|
|
if none is supplied in
|
|
|
|
.IR sun_path .
|
|
|
|
In most cases this is unproblematic:
|
|
|
|
when the socket address is retrieved,
|
|
|
|
it will be one byte longer than that supplied when the socket was bound.
|
|
|
|
However, there is one case where confusing behavior can result:
|
|
|
|
if 108 non-null bytes are supplied when a socket is bound,
|
|
|
|
then the addition of the null terminator takes the length of
|
|
|
|
the pathname beyond
|
|
|
|
.IR sizeof(sun_path) .
|
|
|
|
Consequently, when retrieving the socket address
|
|
|
|
(for example, via
|
|
|
|
.BR accept (2)),
|
|
|
|
.\" The behavior on Solaris is quite similar.
|
|
|
|
if the input
|
|
|
|
.I addrlen
|
|
|
|
argument for the retrieving call is specified as
|
|
|
|
.IR "sizeof(struct sockaddr_un)" ,
|
|
|
|
then the returned address structure
|
|
|
|
.I won't
|
|
|
|
have a null terminator in
|
|
|
|
.IR sun_path .
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
In addition, some implementations
|
|
|
|
.\" i.e., traditional BSD
|
|
|
|
don't require a null terminator when binding a socket (the
|
|
|
|
.I addrlen
|
|
|
|
argument is used to determine the length of
|
|
|
|
.IR sun_path )
|
|
|
|
and when the socket address is retrieved on these implementations,
|
|
|
|
there is no null terminator in
|
|
|
|
.IR sun_path .
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2014-10-15 09:17:46 +00:00
|
|
|
Applications that retrieve socket addresses can (portably) code
|
2012-04-17 10:56:21 +00:00
|
|
|
to handle the possibility that there is no null terminator in
|
|
|
|
.IR sun_path
|
|
|
|
by respecting the fact that the number of valid bytes in the pathname is:
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
strnlen(addr.sun_path, addrlen \- offsetof(sockaddr_un, sun_path))
|
|
|
|
.\" The following patch to amend kernel behavior was rejected:
|
|
|
|
.\" http://thread.gmane.org/gmane.linux.kernel.api/2437
|
|
|
|
.\" Subject: [patch] Fix handling of overlength pathname in AF_UNIX sun_path
|
|
|
|
.\" 2012-04-17
|
|
|
|
.\" And there was a related discussion in the Austin list:
|
|
|
|
.\" http://thread.gmane.org/gmane.comp.standards.posix.austin.general/5735
|
|
|
|
.\" Subject: Having a sun_path with no null terminator
|
|
|
|
.\" 2012-04-18
|
|
|
|
.\"
|
|
|
|
.\" FIXME . Track http://austingroupbugs.net/view.php?id=561
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
Alternatively, an application can retrieve
|
|
|
|
the socket address by allocating a buffer of size
|
|
|
|
.I "sizeof(struct sockaddr_un)+1"
|
|
|
|
that is zeroed out before the retrieval.
|
|
|
|
The retrieving call can specify
|
|
|
|
.I addrlen
|
|
|
|
as
|
|
|
|
.IR "sizeof(struct sockaddr_un)" ,
|
|
|
|
and the extra zero byte ensures that there will be
|
|
|
|
a null terminator for the string returned in
|
|
|
|
.IR sun_path :
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
sinh.3, sockatmark.3, stdarg.3, stpcpy.3, syslog.3, system.3, tanh.3, termios.3, wctrans.3, wctype.3, wcwidth.3, wordexp.3, cciss.4, fuse.4, initrd.4, loop.4, acct.5, hosts.5, nss.5, operator.7, unix.7: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-19 08:28:45 +00:00
|
|
|
.in +4n
|
|
|
|
.EX
|
2012-04-17 10:56:21 +00:00
|
|
|
void *addrp;
|
|
|
|
|
|
|
|
addrlen = sizeof(struct sockaddr_un);
|
|
|
|
addrp = malloc(addrlen + 1);
|
|
|
|
if (addrp == NULL)
|
|
|
|
/* Handle error */ ;
|
|
|
|
memset(addrp, 0, addrlen + 1);
|
|
|
|
|
2014-11-09 20:15:56 +00:00
|
|
|
if (getsockname(sfd, (struct sockaddr *) addrp, &addrlen)) == \-1)
|
2012-04-17 10:56:21 +00:00
|
|
|
/* handle error */ ;
|
|
|
|
|
locale.1, memusage.1, pldd.1, _syscall.2, add_key.2, bind.2, bpf.2, chown.2, clone.2, copy_file_range.2, eventfd.2, execve.2, futex.2, getdents.2, getrlimit.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, listxattr.2, lseek.2, membarrier.2, memfd_create.2, mmap.2, mprotect.2, msgop.2, open_by_handle_at.2, perf_event_open.2, pipe.2, readdir.2, readlink.2, readv.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, select.2, select_tut.2, sendmmsg.2, setns.2, signalfd.2, spu_run.2, stat.2, sysctl.2, tee.2, timer_create.2, timerfd_create.2, truncate.2, uname.2, unshare.2, userfaultfd.2, ustat.2, wait.2, CPU_SET.3, __ppc_get_timebase.3, argz_add.3, asprintf.3, backtrace.3, basename.3, bswap.3, bzero.3, cacos.3, cacosh.3, catan.3, catanh.3, catgets.3, clock_getcpuclockid.3, confstr.3, ctime.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, fgetws.3, fmemopen.3, fopencookie.3, fputws.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrouplist.3, getifaddrs.3, getline.3, getlogin.3, getopt.3, getpass.3, getprotoent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, index.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, iswblank.3, iswspace.3, makecontext.3, mallinfo.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbrtowc.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mcheck.3, memchr.3, mq_getattr.3, mq_notify.3, newlocale.3, nl_langinfo.3, offsetof.3, perror.3, posix_spawn.3, printf.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, qsort.3, rand.3, readdir.3, regex.3, rpmatch.3, rtime.3, scanf.3, sem_wait.3, setaliasent.3, setbuf.3, stpcpy.3, stpncpy.3, strcat.3, strchr.3, strcpy.3, strdup.3, strerror.3, strfromd.3, strftime.3, strlen.3, strnlen.3, strsep.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, termios.3, tsearch.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscat.3, wcscpy.3, wcslen.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcsrtombs.3, wcsstr.3, wcstok.3, wcstombs.3, wcwidth.3, wprintf.3, console_codes.4, dsp56k.4, full.4, initrd.4, loop.4, vcs.4, charmap.5, core.5, elf.5, locale.5, proc.5, repertoiremap.5, sysfs.5, termcap.5, aio.7, bpf-helpers.7, cgroups.7, charsets.7, complex.7, fanotify.7, feature_test_macros.7, inotify.7, locale.7, man-pages.7, man.7, pkeys.7, pthreads.7, rtld-audit.7, sock_diag.7, unix.7, user_namespaces.7, utf-8.7: Use '\e' rather than '\\' to get a backslash
Quoting Branden:
*roff escape sequences may sometimes look like C escapes, but that
is misleading. *roff is in part a macro language and that means
recursive expansion to arbitrary depths.
You can get away with "\\" in a context where no macro expansion
is taking place, but try to spell a literal backslash this way in
the argument to a macro and you will likely be unhappy with
results.
Try viewing the attached file with "man -l".
"\e" is the preferred and portable way to get a portable "escape
literal" going back to CSTR #54, the original Bell Labs troff
paper.
groff(7) discusses the issue:
\\ reduces to a single backslash; useful to delay its
interpretation as escape character in copy mode. For a
printable backslash, use \e, or even better \[rs], to be
independent from the current escape character.
As of groff 1.22.4, groff_man(7) does as well:
\e Widely used in man pages to represent a backslash output
glyph. It works reliably as long as the .ec request is
not used, which should never happen in man pages, and it
is slightly more portable than the more exact ‘\(rs’
(“reverse solidus”) escape sequence.
People not concerned with portability to extremely old troffs should
probably just use \(rs (or \[rs]), as it means "the backslash
glyph", not "the glyph corresponding to whatever the current escape
character is".
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-27 11:57:17 +00:00
|
|
|
printf("sun_path = %s\en", ((struct sockaddr_un *) addrp)\->sun_path);
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EE
|
ioctl_console.2, ioctl_getfsmap.2, ioctl_iflags.2, ioctl_list.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, link.2, mmap.2, modify_ldt.2, msgctl.2, poll.2, query_module.2, quotactl.2, recv.2, recvmmsg.2, sched_setscheduler.2, seccomp.2, select.2, semctl.2, semop.2, send.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sysinfo.2, timer_create.2, timerfd_create.2, uname.2, unshare.2, userfaultfd.2, ustat.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, backtrace.3, bswap.3, btree.3, clock_getcpuclockid.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, fmemopen.3, fopencookie.3, frexp.3, fts.3, ftw.3, getaddrinfo.3, getaddrinfo_a.3, getcontext.3, getgrouplist.3, getifaddrs.3, getipnodebyname.3, getnameinfo.3, getopt.3, getprotoent_r.3, getpwent_r.3, getrpcent.3, getservent_r.3, getttyent.3, getumask.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, inet.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallopt.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mtrace.3, newlocale.3, ntp_gettime.3, offsetof.3, posix_openpt.3, printf.3, pthread_setname_np.3, pthread_setschedparam.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, sigvec.3, stdarg.3, strcat.3, strcpy.3, strftime.3, strtol.3, toupper.3, ttyslot.3, fuse.4, loop.4, st.4, elf.5, cgroup_namespaces.7, cgroups.7, feature_test_macros.7, inode.7, inotify.7, keyrings.7, man-pages.7, math_error.7, mount_namespaces.7, mq_overview.7, pthreads.7, sched.7, session-keyring.7, udplite.7, unix.7, vdso.7: Use consistent markup for code snippets
The preferred form is
.PP/.IP
.in +4n
.EX
<code>
.EE
.in
.PP/.IP
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:37:55 +00:00
|
|
|
.in
|
environ.7, epoll.7, feature_test_macros.7, futex.7, ip.7, ipv6.7, locale.7, man-pages.7, man.7, math_error.7, netdevice.7, netlink.7, packet.7, raw.7, rtld-audit.7, rtnetlink.7, sock_diag.7, socket.7, tcp.7, udp.7, udplite.7, unix.7, uri.7, vdso.7: Formatting fix: replace blank lines with .PP/.IP
Blank lines shouldn't generally appear in *roff source (other
than in code examples), since they create large vertical
spaces between text blocks.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 01:01:48 +00:00
|
|
|
.PP
|
2012-04-17 10:56:21 +00:00
|
|
|
This sort of messiness can be avoided if it is guaranteed
|
|
|
|
that the applications that
|
|
|
|
.I create
|
|
|
|
pathname sockets follow the rules outlined above under
|
|
|
|
.IR "Pathname sockets" .
|
2008-08-08 16:41:48 +00:00
|
|
|
.SH EXAMPLE
|
2016-01-08 19:47:20 +00:00
|
|
|
The following code demonstrates the use of sequenced-packet
|
|
|
|
sockets for local interprocess communication.
|
2016-01-08 19:40:30 +00:00
|
|
|
It consists of two programs.
|
2016-01-06 22:57:32 +00:00
|
|
|
The server program waits for a connection from the client program.
|
2016-01-08 19:47:20 +00:00
|
|
|
The client sends each of its command-line arguments in separate messages.
|
|
|
|
The server treats the incoming messages as integers and adds them up.
|
2016-01-08 19:40:30 +00:00
|
|
|
The client sends the command string "END".
|
2016-01-08 19:47:20 +00:00
|
|
|
The server sends back a message containing the sum of the client's integers.
|
|
|
|
The client prints the sum and exits.
|
2016-01-06 22:57:32 +00:00
|
|
|
The server waits for the next client to connect.
|
2016-01-08 19:47:20 +00:00
|
|
|
To stop the server, the client is called with the command-line argument "DOWN".
|
2016-01-06 22:57:32 +00:00
|
|
|
.PP
|
|
|
|
The following output was recorded while running the server in the background
|
2016-01-08 19:47:20 +00:00
|
|
|
and repeatedly executing the client.
|
|
|
|
Execution of the server program ends when it receives the "DOWN" command.
|
2016-01-06 22:57:32 +00:00
|
|
|
.SS Example output
|
|
|
|
.in +4n
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EX
|
2016-01-08 19:40:30 +00:00
|
|
|
$ \fB./server &\fP
|
2016-01-06 22:57:32 +00:00
|
|
|
[1] 25887
|
2016-01-08 19:40:30 +00:00
|
|
|
$ \fB./client 3 4\fP
|
2016-01-06 22:57:32 +00:00
|
|
|
Result = 7
|
2016-01-08 19:40:30 +00:00
|
|
|
$ \fB./client 11 \-5\fP
|
2016-01-06 22:57:32 +00:00
|
|
|
Result = 6
|
2016-01-08 19:40:30 +00:00
|
|
|
$ \fB./client DOWN\fP
|
2016-01-06 22:57:32 +00:00
|
|
|
Result = 0
|
|
|
|
[1]+ Done ./server
|
|
|
|
$
|
execve.2, ioctl_console.2, ioctl_iflags.2, ioctl_ns.2, ioctl_userfaultfd.2, kcmp.2, kexec_load.2, keyctl.2, link.2, listxattr.2, membarrier.2, memfd_create.2, mmap.2, modify_ldt.2, mprotect.2, msgctl.2, nanosleep.2, open_by_handle_at.2, perf_event_open.2, poll.2, posix_fadvise.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, readdir.2, readv.2, recv.2, recvmmsg.2, request_key.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setattr.2, sched_setscheduler.2, seccomp.2, select.2, select_tut.2, semctl.2, semop.2, send.2, sendmmsg.2, set_thread_area.2, setns.2, shmctl.2, shmget.2, sigaction.2, sigaltstack.2, signal.2, sigwaitinfo.2, stat.2, statfs.2, statx.2, sync_file_range.2, syscall.2, sysctl.2, sysinfo.2, tee.2, timer_create.2, timer_settime.2, timerfd_create.2, unshare.2, userfaultfd.2, ustat.2, utime.2, utimensat.2, vmsplice.2, wait.2, adjtime.3, aio_init.3, backtrace.3, basename.3, bswap.3, btree.3, clock_getcpuclockid.3, cmsg.3, confstr.3, dbopen.3, dl_iterate_phdr.3, dladdr.3, dlinfo.3, dlopen.3, duplocale.3, encrypt.3, end.3, endian.3, err.3, errno.3, ether_aton.3, fgetgrent.3, fgetpwent.3, fmemopen.3, frexp.3, ftime.3, fts.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, getifaddrs.3, getipnodebyname.3, getmntent.3, getnameinfo.3, getnetent.3, getopt.3, getprotoent.3, getprotoent_r.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, glob.3, gnu_get_libc_version.3, hash.3, hsearch.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, isalpha.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, memchr.3, mq_getattr.3, mq_open.3, mq_receive.3, mq_send.3, mtrace.3, newlocale.3, ntp_gettime.3, posix_openpt.3, printf.3, pthread_attr_init.3, pthread_attr_setschedparam.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_cleanup_push_defer_np.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, pthread_tryjoin_np.3, readdir.3, realpath.3, recno.3, regex.3, rpc.3, scanf.3, sched_getcpu.3, sem_wait.3, setaliasent.3, sigqueue.3, statvfs.3, strcat.3, strcpy.3, strftime.3, strtok.3, strtol.3, strverscmp.3, toupper.3, ttyslot.3, xdr.3, fuse.4, loop.4, rtc.4, st.4, acct.5, core.5, elf.5, slabinfo.5, aio.7, arp.7, capabilities.7, cgroup_namespaces.7, cgroups.7, ddp.7, fanotify.7, feature_test_macros.7, inode.7, inotify.7, ip.7, keyrings.7, locale.7, mount_namespaces.7, namespaces.7, netdevice.7, netlink.7, packet.7, pkeys.7, pthreads.7, sched.7, session-keyring.7, sock_diag.7, socket.7, spufs.7, udplite.7, unix.7, user_namespaces.7, vdso.7, x25.7, ld.so.8: Use consistent markup for code snippets
Change .nf/.fi to .EX/.EE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-18 19:52:46 +00:00
|
|
|
.EE
|
2016-01-06 22:57:32 +00:00
|
|
|
.in
|
|
|
|
.SS Program source
|
getrlimit.2, signalfd.2, statfs.2, tee.2, dlopen.3, duplocale.3, ftw.3, get_nprocs.3, mbstowcs.3, posix_spawn.3, strftime.3, full.4, fanotify.7, inotify.7, ip.7, netdevice.7, rtld-audit.7, unix.7: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-19 19:02:23 +00:00
|
|
|
\&
|
memusage.1, clone.2, eventfd.2, futex.2, getdents.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, keyctl.2, mmap.2, mprotect.2, msgop.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, setns.2, tee.2, timer_create.2, timerfd_create.2, unshare.2, userfaultfd.2, wait.2, __ppc_get_timebase.3, backtrace.3, bswap.3, clock_getcpuclockid.3, dl_iterate_phdr.3, dlinfo.3, dlopen.3, duplocale.3, end.3, endian.3, fmemopen.3, fopencookie.3, frexp.3, ftw.3, getdate.3, getgrouplist.3, getifaddrs.3, getprotoent_r.3, getservent_r.3, gnu_get_libc_version.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, mq_getattr.3, mq_notify.3, newlocale.3, offsetof.3, posix_spawn.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, scandir.3, sem_wait.3, strcat.3, strftime.3, strtok.3, strtol.3, strverscmp.3, loop.4, core.5, aio.7, fanotify.7, feature_test_macros.7, inotify.7, pkeys.7, unix.7, user_namespaces.7: Use .EX/.EE for EXAMPLE programs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 08:44:33 +00:00
|
|
|
.EX
|
2016-01-06 22:57:32 +00:00
|
|
|
/*
|
|
|
|
* File connection.h
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SOCKET_NAME "/tmp/9Lq7BNBnBycd6nxy.socket"
|
|
|
|
#define BUFFER_SIZE 12
|
|
|
|
|
|
|
|
/*
|
|
|
|
* File server.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "connection.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
struct sockaddr_un name;
|
|
|
|
int down_flag = 0;
|
|
|
|
int ret;
|
|
|
|
int connection_socket;
|
|
|
|
int data_socket;
|
|
|
|
int result;
|
|
|
|
char buffer[BUFFER_SIZE];
|
|
|
|
|
|
|
|
/*
|
2016-01-08 19:40:30 +00:00
|
|
|
* In case the program exited inadvertently on the last run,
|
2016-01-06 22:57:32 +00:00
|
|
|
* remove the socket.
|
|
|
|
*/
|
|
|
|
|
|
|
|
unlink(SOCKET_NAME);
|
|
|
|
|
|
|
|
/* Create local socket. */
|
|
|
|
|
|
|
|
connection_socket = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
|
|
|
if (connection_socket == \-1) {
|
|
|
|
perror("socket");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-01-08 19:40:30 +00:00
|
|
|
* For portability clear the whole structure, since some
|
|
|
|
* implementations have additional (nonstandard) fields in
|
|
|
|
* the structure.
|
2016-01-06 22:57:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
memset(&name, 0, sizeof(struct sockaddr_un));
|
|
|
|
|
|
|
|
/* Bind socket to socket name. */
|
|
|
|
|
|
|
|
name.sun_family = AF_UNIX;
|
|
|
|
strncpy(name.sun_path, SOCKET_NAME, sizeof(name.sun_path) \- 1);
|
|
|
|
|
|
|
|
ret = bind(connection_socket, (const struct sockaddr *) &name,
|
|
|
|
sizeof(struct sockaddr_un));
|
|
|
|
if (ret == \-1) {
|
|
|
|
perror("bind");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-01-08 19:40:30 +00:00
|
|
|
* Prepare for accepting connections. The backlog size is set
|
|
|
|
* to 20. So while one request is being processed other requests
|
|
|
|
* can be waiting.
|
2016-01-06 22:57:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
ret = listen(connection_socket, 20);
|
|
|
|
if (ret == \-1) {
|
|
|
|
perror("listen");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This is the main loop for handling connections. */
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
|
|
|
|
/* Wait for incoming connection. */
|
|
|
|
|
|
|
|
data_socket = accept(connection_socket, NULL, NULL);
|
2016-05-12 08:24:26 +00:00
|
|
|
if (data_socket == \-1) {
|
2016-01-06 22:57:32 +00:00
|
|
|
perror("accept");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = 0;
|
2018-07-08 19:52:37 +00:00
|
|
|
for (;;) {
|
2016-01-06 22:57:32 +00:00
|
|
|
|
|
|
|
/* Wait for next data packet. */
|
|
|
|
|
|
|
|
ret = read(data_socket, buffer, BUFFER_SIZE);
|
|
|
|
if (ret == \-1) {
|
2016-01-08 19:40:30 +00:00
|
|
|
perror("read");
|
2016-01-06 22:57:32 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure buffer is 0\-terminated. */
|
|
|
|
|
|
|
|
buffer[BUFFER_SIZE \- 1] = 0;
|
|
|
|
|
|
|
|
/* Handle commands. */
|
|
|
|
|
|
|
|
if (!strncmp(buffer, "DOWN", BUFFER_SIZE)) {
|
|
|
|
down_flag = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strncmp(buffer, "END", BUFFER_SIZE)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add received summand. */
|
|
|
|
|
|
|
|
result += atoi(buffer);
|
|
|
|
}
|
2011-09-15 00:41:59 +00:00
|
|
|
|
2016-01-06 22:57:32 +00:00
|
|
|
/* Send result. */
|
|
|
|
|
|
|
|
sprintf(buffer, "%d", result);
|
|
|
|
ret = write(data_socket, buffer, BUFFER_SIZE);
|
|
|
|
if (ret == \-1) {
|
2016-01-08 19:40:30 +00:00
|
|
|
perror("write");
|
2016-01-06 22:57:32 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Close socket. */
|
|
|
|
|
|
|
|
close(data_socket);
|
|
|
|
|
|
|
|
/* Quit on DOWN command. */
|
|
|
|
|
|
|
|
if (down_flag) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close(connection_socket);
|
|
|
|
|
|
|
|
/* Unlink the socket. */
|
|
|
|
|
|
|
|
unlink(SOCKET_NAME);
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* File client.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/un.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include "connection.h"
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char *argv[])
|
|
|
|
{
|
accept.2, bind.2, connect.2, getpeername.2, getsockname.2, recv.2, recvmmsg.2, select_tut.2, send.2, sendmmsg.2, getaddrinfo.3, getnameinfo.3, epoll.7, unix.7: Use consistent argument/variable names for socket addresses and lengths
As noted by Carlos, there's quite a bit of inconsistency across
pages. Use 'addr' and 'addrlen' consistently in variables and
function arguments.
Cowritten-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-02-03 12:10:04 +00:00
|
|
|
struct sockaddr_un addr;
|
2016-01-06 22:57:32 +00:00
|
|
|
int i;
|
|
|
|
int ret;
|
|
|
|
int data_socket;
|
|
|
|
char buffer[BUFFER_SIZE];
|
|
|
|
|
|
|
|
/* Create local socket. */
|
|
|
|
|
|
|
|
data_socket = socket(AF_UNIX, SOCK_SEQPACKET, 0);
|
|
|
|
if (data_socket == \-1) {
|
|
|
|
perror("socket");
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2016-01-08 19:40:30 +00:00
|
|
|
* For portability clear the whole structure, since some
|
|
|
|
* implementations have additional (nonstandard) fields in
|
|
|
|
* the structure.
|
2016-01-06 22:57:32 +00:00
|
|
|
*/
|
|
|
|
|
accept.2, bind.2, connect.2, getpeername.2, getsockname.2, recv.2, recvmmsg.2, select_tut.2, send.2, sendmmsg.2, getaddrinfo.3, getnameinfo.3, epoll.7, unix.7: Use consistent argument/variable names for socket addresses and lengths
As noted by Carlos, there's quite a bit of inconsistency across
pages. Use 'addr' and 'addrlen' consistently in variables and
function arguments.
Cowritten-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-02-03 12:10:04 +00:00
|
|
|
memset(&addr, 0, sizeof(struct sockaddr_un));
|
2016-01-06 22:57:32 +00:00
|
|
|
|
accept.2, bind.2, connect.2, getpeername.2, getsockname.2, recv.2, recvmmsg.2, select_tut.2, send.2, sendmmsg.2, getaddrinfo.3, getnameinfo.3, epoll.7, unix.7: Use consistent argument/variable names for socket addresses and lengths
As noted by Carlos, there's quite a bit of inconsistency across
pages. Use 'addr' and 'addrlen' consistently in variables and
function arguments.
Cowritten-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-02-03 12:10:04 +00:00
|
|
|
/* Connect socket to socket address */
|
2016-01-06 22:57:32 +00:00
|
|
|
|
accept.2, bind.2, connect.2, getpeername.2, getsockname.2, recv.2, recvmmsg.2, select_tut.2, send.2, sendmmsg.2, getaddrinfo.3, getnameinfo.3, epoll.7, unix.7: Use consistent argument/variable names for socket addresses and lengths
As noted by Carlos, there's quite a bit of inconsistency across
pages. Use 'addr' and 'addrlen' consistently in variables and
function arguments.
Cowritten-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-02-03 12:10:04 +00:00
|
|
|
addr.sun_family = AF_UNIX;
|
|
|
|
strncpy(addr.sun_path, SOCKET_NAME, sizeof(addr.sun_path) \- 1);
|
2016-01-06 22:57:32 +00:00
|
|
|
|
accept.2, bind.2, connect.2, getpeername.2, getsockname.2, recv.2, recvmmsg.2, select_tut.2, send.2, sendmmsg.2, getaddrinfo.3, getnameinfo.3, epoll.7, unix.7: Use consistent argument/variable names for socket addresses and lengths
As noted by Carlos, there's quite a bit of inconsistency across
pages. Use 'addr' and 'addrlen' consistently in variables and
function arguments.
Cowritten-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2016-02-03 12:10:04 +00:00
|
|
|
ret = connect (data_socket, (const struct sockaddr *) &addr,
|
2016-01-06 22:57:32 +00:00
|
|
|
sizeof(struct sockaddr_un));
|
|
|
|
if (ret == \-1) {
|
locale.1, memusage.1, pldd.1, _syscall.2, add_key.2, bind.2, bpf.2, chown.2, clone.2, copy_file_range.2, eventfd.2, execve.2, futex.2, getdents.2, getrlimit.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, listxattr.2, lseek.2, membarrier.2, memfd_create.2, mmap.2, mprotect.2, msgop.2, open_by_handle_at.2, perf_event_open.2, pipe.2, readdir.2, readlink.2, readv.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, select.2, select_tut.2, sendmmsg.2, setns.2, signalfd.2, spu_run.2, stat.2, sysctl.2, tee.2, timer_create.2, timerfd_create.2, truncate.2, uname.2, unshare.2, userfaultfd.2, ustat.2, wait.2, CPU_SET.3, __ppc_get_timebase.3, argz_add.3, asprintf.3, backtrace.3, basename.3, bswap.3, bzero.3, cacos.3, cacosh.3, catan.3, catanh.3, catgets.3, clock_getcpuclockid.3, confstr.3, ctime.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, fgetws.3, fmemopen.3, fopencookie.3, fputws.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrouplist.3, getifaddrs.3, getline.3, getlogin.3, getopt.3, getpass.3, getprotoent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, index.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, iswblank.3, iswspace.3, makecontext.3, mallinfo.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbrtowc.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mcheck.3, memchr.3, mq_getattr.3, mq_notify.3, newlocale.3, nl_langinfo.3, offsetof.3, perror.3, posix_spawn.3, printf.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, qsort.3, rand.3, readdir.3, regex.3, rpmatch.3, rtime.3, scanf.3, sem_wait.3, setaliasent.3, setbuf.3, stpcpy.3, stpncpy.3, strcat.3, strchr.3, strcpy.3, strdup.3, strerror.3, strfromd.3, strftime.3, strlen.3, strnlen.3, strsep.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, termios.3, tsearch.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscat.3, wcscpy.3, wcslen.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcsrtombs.3, wcsstr.3, wcstok.3, wcstombs.3, wcwidth.3, wprintf.3, console_codes.4, dsp56k.4, full.4, initrd.4, loop.4, vcs.4, charmap.5, core.5, elf.5, locale.5, proc.5, repertoiremap.5, sysfs.5, termcap.5, aio.7, bpf-helpers.7, cgroups.7, charsets.7, complex.7, fanotify.7, feature_test_macros.7, inotify.7, locale.7, man-pages.7, man.7, pkeys.7, pthreads.7, rtld-audit.7, sock_diag.7, unix.7, user_namespaces.7, utf-8.7: Use '\e' rather than '\\' to get a backslash
Quoting Branden:
*roff escape sequences may sometimes look like C escapes, but that
is misleading. *roff is in part a macro language and that means
recursive expansion to arbitrary depths.
You can get away with "\\" in a context where no macro expansion
is taking place, but try to spell a literal backslash this way in
the argument to a macro and you will likely be unhappy with
results.
Try viewing the attached file with "man -l".
"\e" is the preferred and portable way to get a portable "escape
literal" going back to CSTR #54, the original Bell Labs troff
paper.
groff(7) discusses the issue:
\\ reduces to a single backslash; useful to delay its
interpretation as escape character in copy mode. For a
printable backslash, use \e, or even better \[rs], to be
independent from the current escape character.
As of groff 1.22.4, groff_man(7) does as well:
\e Widely used in man pages to represent a backslash output
glyph. It works reliably as long as the .ec request is
not used, which should never happen in man pages, and it
is slightly more portable than the more exact ‘\(rs’
(“reverse solidus”) escape sequence.
People not concerned with portability to extremely old troffs should
probably just use \(rs (or \[rs]), as it means "the backslash
glyph", not "the glyph corresponding to whatever the current escape
character is".
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-27 11:57:17 +00:00
|
|
|
fprintf(stderr, "The server is down.\en");
|
2016-01-06 22:57:32 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send arguments. */
|
|
|
|
|
|
|
|
for (i = 1; i < argc; ++i) {
|
|
|
|
ret = write(data_socket, argv[i], strlen(argv[i]) + 1);
|
|
|
|
if (ret == \-1) {
|
2016-01-08 19:40:30 +00:00
|
|
|
perror("write");
|
2016-01-06 22:57:32 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Request result. */
|
|
|
|
|
|
|
|
strcpy (buffer, "END");
|
|
|
|
ret = write(data_socket, buffer, strlen(buffer) + 1);
|
|
|
|
if (ret == \-1) {
|
2016-01-08 19:40:30 +00:00
|
|
|
perror("write");
|
2016-01-06 22:57:32 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Receive result. */
|
|
|
|
|
|
|
|
ret = read(data_socket, buffer, BUFFER_SIZE);
|
|
|
|
if (ret == \-1) {
|
2016-01-08 19:40:30 +00:00
|
|
|
perror("read");
|
2016-01-06 22:57:32 +00:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ensure buffer is 0\-terminated. */
|
|
|
|
|
|
|
|
buffer[BUFFER_SIZE \- 1] = 0;
|
|
|
|
|
locale.1, memusage.1, pldd.1, _syscall.2, add_key.2, bind.2, bpf.2, chown.2, clone.2, copy_file_range.2, eventfd.2, execve.2, futex.2, getdents.2, getrlimit.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, kexec_load.2, keyctl.2, listxattr.2, lseek.2, membarrier.2, memfd_create.2, mmap.2, mprotect.2, msgop.2, open_by_handle_at.2, perf_event_open.2, pipe.2, readdir.2, readlink.2, readv.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, select.2, select_tut.2, sendmmsg.2, setns.2, signalfd.2, spu_run.2, stat.2, sysctl.2, tee.2, timer_create.2, timerfd_create.2, truncate.2, uname.2, unshare.2, userfaultfd.2, ustat.2, wait.2, CPU_SET.3, __ppc_get_timebase.3, argz_add.3, asprintf.3, backtrace.3, basename.3, bswap.3, bzero.3, cacos.3, cacosh.3, catan.3, catanh.3, catgets.3, clock_getcpuclockid.3, confstr.3, ctime.3, dl_iterate_phdr.3, dlinfo.3, duplocale.3, encrypt.3, end.3, endian.3, fgetws.3, fmemopen.3, fopencookie.3, fputws.3, frexp.3, ftw.3, get_nprocs_conf.3, get_phys_pages.3, getaddrinfo.3, getaddrinfo_a.3, getdate.3, getgrouplist.3, getifaddrs.3, getline.3, getlogin.3, getopt.3, getpass.3, getprotoent_r.3, getpwnam.3, getservent_r.3, getsubopt.3, glob.3, gnu_get_libc_version.3, hsearch.3, if_nameindex.3, index.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, iswblank.3, iswspace.3, makecontext.3, mallinfo.3, malloc_hook.3, malloc_info.3, mallopt.3, matherr.3, mbrtowc.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mcheck.3, memchr.3, mq_getattr.3, mq_notify.3, newlocale.3, nl_langinfo.3, offsetof.3, perror.3, posix_spawn.3, printf.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_mutexattr_setrobust.3, pthread_setaffinity_np.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, qsort.3, rand.3, readdir.3, regex.3, rpmatch.3, rtime.3, scanf.3, sem_wait.3, setaliasent.3, setbuf.3, stpcpy.3, stpncpy.3, strcat.3, strchr.3, strcpy.3, strdup.3, strerror.3, strfromd.3, strftime.3, strlen.3, strnlen.3, strsep.3, strstr.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, termios.3, tsearch.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscat.3, wcscpy.3, wcslen.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcsrtombs.3, wcsstr.3, wcstok.3, wcstombs.3, wcwidth.3, wprintf.3, console_codes.4, dsp56k.4, full.4, initrd.4, loop.4, vcs.4, charmap.5, core.5, elf.5, locale.5, proc.5, repertoiremap.5, sysfs.5, termcap.5, aio.7, bpf-helpers.7, cgroups.7, charsets.7, complex.7, fanotify.7, feature_test_macros.7, inotify.7, locale.7, man-pages.7, man.7, pkeys.7, pthreads.7, rtld-audit.7, sock_diag.7, unix.7, user_namespaces.7, utf-8.7: Use '\e' rather than '\\' to get a backslash
Quoting Branden:
*roff escape sequences may sometimes look like C escapes, but that
is misleading. *roff is in part a macro language and that means
recursive expansion to arbitrary depths.
You can get away with "\\" in a context where no macro expansion
is taking place, but try to spell a literal backslash this way in
the argument to a macro and you will likely be unhappy with
results.
Try viewing the attached file with "man -l".
"\e" is the preferred and portable way to get a portable "escape
literal" going back to CSTR #54, the original Bell Labs troff
paper.
groff(7) discusses the issue:
\\ reduces to a single backslash; useful to delay its
interpretation as escape character in copy mode. For a
printable backslash, use \e, or even better \[rs], to be
independent from the current escape character.
As of groff 1.22.4, groff_man(7) does as well:
\e Widely used in man pages to represent a backslash output
glyph. It works reliably as long as the .ec request is
not used, which should never happen in man pages, and it
is slightly more portable than the more exact ‘\(rs’
(“reverse solidus”) escape sequence.
People not concerned with portability to extremely old troffs should
probably just use \(rs (or \[rs]), as it means "the backslash
glyph", not "the glyph corresponding to whatever the current escape
character is".
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-02-27 11:57:17 +00:00
|
|
|
printf("Result = %s\en", buffer);
|
2016-01-06 22:57:32 +00:00
|
|
|
|
|
|
|
/* Close socket. */
|
|
|
|
|
|
|
|
close(data_socket);
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
memusage.1, clone.2, eventfd.2, futex.2, getdents.2, ioctl_fat.2, ioctl_ns.2, kcmp.2, keyctl.2, mmap.2, mprotect.2, msgop.2, recvmmsg.2, request_key.2, sched_setaffinity.2, seccomp.2, setns.2, tee.2, timer_create.2, timerfd_create.2, unshare.2, userfaultfd.2, wait.2, __ppc_get_timebase.3, backtrace.3, bswap.3, clock_getcpuclockid.3, dl_iterate_phdr.3, dlinfo.3, dlopen.3, duplocale.3, end.3, endian.3, fmemopen.3, fopencookie.3, frexp.3, ftw.3, getdate.3, getgrouplist.3, getifaddrs.3, getprotoent_r.3, getservent_r.3, gnu_get_libc_version.3, if_nameindex.3, inet.3, inet_net_pton.3, inet_pton.3, insque.3, makecontext.3, mallinfo.3, malloc_info.3, mallopt.3, matherr.3, mbstowcs.3, mcheck.3, mq_getattr.3, mq_notify.3, newlocale.3, offsetof.3, posix_spawn.3, pthread_attr_init.3, pthread_cancel.3, pthread_cleanup_push.3, pthread_create.3, pthread_getattr_default_np.3, pthread_getattr_np.3, pthread_getcpuclockid.3, pthread_setname_np.3, pthread_setschedparam.3, pthread_sigmask.3, scandir.3, sem_wait.3, strcat.3, strftime.3, strtok.3, strtol.3, strverscmp.3, loop.4, core.5, aio.7, fanotify.7, feature_test_macros.7, inotify.7, pkeys.7, unix.7, user_namespaces.7: Use .EX/.EE for EXAMPLE programs
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2017-08-16 08:44:33 +00:00
|
|
|
.EE
|
2016-01-06 22:57:32 +00:00
|
|
|
.PP
|
2011-09-15 00:41:59 +00:00
|
|
|
For an example of the use of
|
|
|
|
.BR SCM_RIGHTS
|
|
|
|
see
|
|
|
|
.BR cmsg (3).
|
getent.1, intro.1, time.1, _exit.2, _syscall.2, accept.2, access.2, acct.2, adjtimex.2, alarm.2, alloc_hugepages.2, arch_prctl.2, bdflush.2, bind.2, brk.2, cacheflush.2, capget.2, chdir.2, chmod.2, chown.2, chroot.2, clock_getres.2, clock_nanosleep.2, clone.2, close.2, connect.2, create_module.2, delete_module.2, dup.2, epoll_create.2, epoll_ctl.2, epoll_wait.2, eventfd.2, execve.2, exit_group.2, faccessat.2, fchmodat.2, fchownat.2, fcntl.2, flock.2, fork.2, fstatat.2, fsync.2, futex.2, futimesat.2, get_kernel_syms.2, get_robust_list.2, get_thread_area.2, getcpu.2, getdents.2, getdomainname.2, getgid.2, getgroups.2, gethostname.2, getitimer.2, getpagesize.2, getpeername.2, getpid.2, getpriority.2, getresuid.2, getrlimit.2, getrusage.2, getsid.2, getsockname.2, getsockopt.2, gettid.2, gettimeofday.2, getuid.2, getunwind.2, getxattr.2, idle.2, init_module.2, inotify_add_watch.2, inotify_init.2, inotify_rm_watch.2, intro.2, io_cancel.2, io_destroy.2, io_getevents.2, io_setup.2, io_submit.2, ioctl.2, ioctl_list.2, ioperm.2, iopl.2, ioprio_set.2, ipc.2, kcmp.2, kill.2, killpg.2, link.2, linkat.2, listen.2, listxattr.2, llseek.2, lookup_dcookie.2, lseek.2, madvise.2, migrate_pages.2, mincore.2, mkdir.2, mkdirat.2, mknod.2, mknodat.2, mlock.2, mmap.2, mmap2.2, modify_ldt.2, mount.2, move_pages.2, mprotect.2, mq_getsetattr.2, mremap.2, msgctl.2, msgget.2, msgop.2, msync.2, nanosleep.2, nfsservctl.2, nice.2, open.2, openat.2, outb.2, pause.2, pciconfig_read.2, perf_event_open.2, perfmonctl.2, personality.2, pipe.2, pivot_root.2, poll.2, posix_fadvise.2, prctl.2, pread.2, process_vm_readv.2, ptrace.2, query_module.2, quotactl.2, read.2, readahead.2, readdir.2, readlink.2, readlinkat.2, readv.2, reboot.2, recv.2, remap_file_pages.2, removexattr.2, rename.2, renameat.2, rmdir.2, rt_sigqueueinfo.2, sched_get_priority_max.2, sched_rr_get_interval.2, sched_setaffinity.2, sched_setparam.2, sched_setscheduler.2, sched_yield.2, select.2, semctl.2, semget.2, semop.2, send.2, sendfile.2, set_thread_area.2, set_tid_address.2, seteuid.2, setfsgid.2, setfsuid.2, setgid.2, setpgid.2, setresuid.2, setreuid.2, setsid.2, setuid.2, setup.2, setxattr.2, shmctl.2, shmget.2, shmop.2, shutdown.2, sigaction.2, sigaltstack.2, signal.2, signalfd.2, sigpending.2, sigprocmask.2, sigreturn.2, sigsuspend.2, sigwaitinfo.2, socket.2, socketcall.2, socketpair.2, splice.2, stat.2, statfs.2, stime.2, swapon.2, symlink.2, symlinkat.2, sync.2, sync_file_range.2, sysctl.2, sysfs.2, sysinfo.2, syslog.2, tee.2, time.2, timerfd_create.2, times.2, tkill.2, truncate.2, umask.2, umount.2, uname.2, unimplemented.2, unlink.2, unlinkat.2, uselib.2, ustat.2, utime.2, utimensat.2, vfork.2, vhangup.2, vm86.2, vmsplice.2, wait.2, wait4.2, write.2, CPU_SET.3, INFINITY.3, MB_CUR_MAX.3, MB_LEN_MAX.3, __setfpucw.3, a64l.3, abort.3, abs.3, acos.3, acosh.3, addseverity.3, adjtime.3, aio_cancel.3, aio_error.3, aio_fsync.3, aio_read.3, aio_return.3, aio_suspend.3, aio_write.3, alloca.3, argz_add.3, asin.3, asinh.3, asprintf.3, assert.3, assert_perror.3, atan.3, atan2.3, atanh.3, atexit.3, atof.3, atoi.3, backtrace.3, basename.3, bcmp.3, bcopy.3, bindresvport.3, bsd_signal.3, bsearch.3, bstring.3, btowc.3, btree.3, byteorder.3, bzero.3, cabs.3, cacos.3, cacosh.3, canonicalize_file_name.3, carg.3, casin.3, casinh.3, catan.3, catanh.3, catgets.3, catopen.3, cbrt.3, ccos.3, ccosh.3, ceil.3, cerf.3, cexp.3, cexp2.3, cfree.3, cimag.3, clearenv.3, clock.3, clock_getcpuclockid.3, clog.3, clog10.3, clog2.3, closedir.3, cmsg.3, confstr.3, conj.3, copysign.3, cos.3, cosh.3, cpow.3, cproj.3, creal.3, crypt.3, csin.3, csinh.3, csqrt.3, ctan.3, ctanh.3, ctermid.3, ctime.3, daemon.3, dbopen.3, des_crypt.3, difftime.3, dirfd.3, div.3, dl_iterate_phdr.3, dlopen.3, dprintf.3, drand48.3, drand48_r.3, dysize.3, ecvt.3, ecvt_r.3, encrypt.3, end.3, endian.3, envz_add.3, erf.3, erfc.3, err.3, errno.3, error.3, ether_aton.3, euidaccess.3, exec.3, exit.3, exp.3, exp10.3, exp2.3, expm1.3, fabs.3, fclose.3, fcloseall.3, fdim.3, fenv.3, ferror.3, fexecve.3, fflush.3, ffs.3, fgetgrent.3, fgetpwent.3, fgetwc.3, fgetws.3, finite.3, flockfile.3, floor.3, fma.3, fmax.3, fmemopen.3, fmin.3, fmod.3, fmtmsg.3, fnmatch.3, fopen.3, fpathconf.3, fpclassify.3, fpurge.3, fputwc.3, fputws.3, fread.3, frexp.3, fseek.3, fseeko.3, ftime.3, ftok.3, fts.3, ftw.3, futimes.3, fwide.3, gamma.3, gcvt.3, getaddrinfo.3, getaddrinfo_a.3, getauxval.3, getcontext.3, getcwd.3, getdate.3, getdirentries.3, getdtablesize.3, getenv.3, getfsent.3, getgrent.3, getgrent_r.3, getgrnam.3, getgrouplist.3, gethostbyname.3, gethostid.3, getipnodebyname.3, getline.3, getloadavg.3, getlogin.3, getmntent.3, getnameinfo.3, getnetent.3, getnetent_r.3, getopt.3, getpass.3, getprotoent.3, getprotoent_r.3, getpt.3, getpw.3, getpwent.3, getpwent_r.3, getpwnam.3, getrpcent.3, getrpcent_r.3, getrpcport.3, gets.3, getservent.3, getservent_r.3, getspnam.3, getttyent.3, getumask.3, getusershell.3, getutent.3, getw.3, getwchar.3, glob.3, grantpt.3, gsignal.3, hash.3, hsearch.3, hypot.3, iconv.3, iconv_close.3, iconv_open.3, ilogb.3, index.3, inet.3, inet_ntop.3, inet_pton.3, infnan.3, initgroups.3, insque.3, intro.3, isalpha.3, isatty.3, isgreater.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, j0.3, key_setsecret.3, ldexp.3, lgamma.3, lio_listio.3, localeconv.3, lockf.3, log.3, log10.3, log1p.3, log2.3, logb.3, login.3, longjmp.3, lrint.3, lround.3, lsearch.3, lseek64.3, makecontext.3, makedev.3, malloc.3, malloc_hook.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, memccpy.3, memchr.3, memcmp.3, memcpy.3, memfrob.3, memmem.3, memmove.3, mempcpy.3, memset.3, mkdtemp.3, mkfifo.3, mkfifoat.3, mkstemp.3, mktemp.3, modf.3, mpool.3, mq_close.3, mq_getattr.3, mq_notify.3, mq_open.3, mq_receive.3, mq_send.3, mq_unlink.3, mtrace.3, nan.3, netlink.3, nextafter.3, nl_langinfo.3, offsetof.3, on_exit.3, opendir.3, openpty.3, perror.3, popen.3, posix_fallocate.3, posix_memalign.3, posix_openpt.3, pow.3, pow10.3, printf.3, profil.3, program_invocation_name.3, psignal.3, pthread_kill_other_threads_np.3, ptsname.3, putenv.3, putgrent.3, putpwent.3, puts.3, putwchar.3, qecvt.3, qsort.3, queue.3, raise.3, rand.3, random.3, random_r.3, rcmd.3, re_comp.3, readdir.3, realpath.3, recno.3, regex.3, remainder.3, remove.3, remquo.3, resolver.3, rewinddir.3, rexec.3, rint.3, round.3, rpc.3, rpmatch.3, rtime.3, rtnetlink.3, scalb.3, scalbln.3, scandir.3, scandirat.3, scanf.3, seekdir.3, sem_close.3, sem_destroy.3, sem_getvalue.3, sem_init.3, sem_open.3, sem_post.3, sem_unlink.3, sem_wait.3, setaliasent.3, setbuf.3, setenv.3, setjmp.3, setlocale.3, setlogmask.3, setnetgrent.3, shm_open.3, siginterrupt.3, signbit.3, significand.3, sigpause.3, sigqueue.3, sigset.3, sigsetops.3, sigvec.3, sin.3, sincos.3, sinh.3, sleep.3, sockatmark.3, sqrt.3, statvfs.3, stdarg.3, stdin.3, stdio.3, stdio_ext.3, stpcpy.3, stpncpy.3, strcasecmp.3, strcat.3, strchr.3, strcmp.3, strcoll.3, strcpy.3, strdup.3, strerror.3, strfmon.3, strfry.3, strftime.3, string.3, strlen.3, strnlen.3, strpbrk.3, strptime.3, strsep.3, strsignal.3, strspn.3, strstr.3, strtod.3, strtoimax.3, strtok.3, strtol.3, strtoul.3, strverscmp.3, strxfrm.3, swab.3, sysconf.3, syslog.3, system.3, sysv_signal.3, tan.3, tanh.3, tcgetpgrp.3, tcgetsid.3, telldir.3, tempnam.3, termios.3, tgamma.3, timegm.3, timeradd.3, tmpfile.3, tmpnam.3, toascii.3, toupper.3, towctrans.3, towlower.3, towupper.3, trunc.3, tsearch.3, ttyname.3, ttyslot.3, tzset.3, ualarm.3, ulimit.3, ungetwc.3, unlocked_stdio.3, unlockpt.3, updwtmp.3, usleep.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstoimax.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wordexp.3, wprintf.3, xcrypt.3, xdr.3, y0.3, cciss.4, console.4, console_codes.4, console_ioctl.4, dsp56k.4, fd.4, full.4, hd.4, hpsa.4, initrd.4, intro.4, lp.4, mem.4, mouse.4, null.4, pts.4, ram.4, random.4, rtc.4, sk98lin.4, st.4, tty.4, ttyS.4, tty_ioctl.4, vcs.4, wavelan.4, acct.5, charmap.5, dir_colors.5, filesystems.5, ftpusers.5, group.5, host.conf.5, hosts.5, hosts.equiv.5, intro.5, issue.5, locale.5, motd.5, networks.5, nologin.5, nscd.conf.5, passwd.5, proc.5, protocols.5, resolv.conf.5, rpc.5, securetty.5, services.5, shells.5, termcap.5, ttytype.5, utmp.5, armscii-8.7, arp.7, ascii.7, bootparam.7, capabilities.7, charsets.7, complex.7, cp1251.7, credentials.7, ddp.7, environ.7, epoll.7, fifo.7, futex.7, glob.7, hier.7, icmp.7, inotify.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, locale.7, mailaddr.7, man.7, mq_overview.7, netdevice.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, posixoptions.7, pthreads.7, pty.7, raw.7, regex.7, rtld-audit.7, rtnetlink.7, sem_overview.7, shm_overview.7, sigevent.7, signal.7, socket.7, standards.7, suffixes.7, svipc.7, tcp.7, termio.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, nscd.8, sync.8, tzselect.8, zdump.8, zic.8: Global fix: remove unneeded double quotes in .SH headings
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 18:01:36 +00:00
|
|
|
.SH SEE ALSO
|
2008-08-08 16:41:48 +00:00
|
|
|
.BR recvmsg (2),
|
|
|
|
.BR sendmsg (2),
|
|
|
|
.BR socket (2),
|
|
|
|
.BR socketpair (2),
|
|
|
|
.BR cmsg (3),
|
|
|
|
.BR capabilities (7),
|
|
|
|
.BR credentials (7),
|
2014-10-18 15:36:00 +00:00
|
|
|
.BR socket (7),
|
|
|
|
.BR udp (7)
|