1.\" $OpenBSD: sendsyslog.2,v 1.12 2020/11/05 16:04:39 jmc Exp $ 2.\" 3.\" Copyright (c) 2017 Alexander Bluhm <bluhm@openbsd.org> 4.\" Copyright (c) 2014 Theo de Raadt 5.\" 6.\" Permission to use, copy, modify, and distribute this software for any 7.\" purpose with or without fee is hereby granted, provided that the above 8.\" copyright notice and this permission notice appear in all copies. 9.\" 10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17.\" 18.Dd $Mdocdate: November 5 2020 $ 19.Dt SENDSYSLOG 2 20.Os 21.Sh NAME 22.Nm sendsyslog 23.Nd send a message to syslogd 24.Sh SYNOPSIS 25.In sys/syslog.h 26.In sys/types.h 27.Ft int 28.Fn sendsyslog "const char *msg" "size_t len" "int flags" 29.Sh DESCRIPTION 30The 31.Fn sendsyslog 32function is used to transmit a 33.Xr syslog 3 34formatted message direct to 35.Xr syslogd 8 36without requiring the allocation of a socket. 37The 38.Fa msg 39is not NUL terminated and its 40.Fa len 41is limited to 8192 bytes. 42If 43.Dv LOG_CONS 44is specified in the 45.Fa flags 46argument, and 47.Xr syslogd 8 48is not accepting messages, the message will be sent to the console. 49This is used internally by 50.Xr syslog_r 3 , 51so that messages can be sent during difficult situations. 52If sending to 53.Xr syslogd 8 54fails, dropped messages are counted. 55When 56.Xr syslogd 8 57works again, a warning with the counter and error number is logged. 58.Pp 59To receive messages from the kernel, 60.Xr syslogd 8 61has to create a datagram socket pair and register one end. 62This registration is done by opening the 63.Pa /dev/klog 64device and passing one file descriptor of the socket pair as argument 65to 66.Xr ioctl 2 Dv LIOCSFD 67invoked on the klog file descriptor. 68After that the messages can be read from the other end of the 69socket pair. 70By utilizing 71.Pa /dev/klog 72the access to log messages is limited to processes that may open 73this device. 74.Sh RETURN VALUES 75.Rv -std 76.Sh ERRORS 77.Fn sendsyslog 78can fail if: 79.Bl -tag -width Er 80.It Bq Er EFAULT 81An invalid user space address was specified for a parameter. 82.It Bq Er EMSGSIZE 83The socket requires that message be sent atomically, 84and the size of the message to be sent made this impossible. 85.It Bq Er ENOBUFS 86The system was unable to allocate an internal buffer. 87The operation may succeed when buffers become available. 88.It Bq Er ENOTCONN 89The message cannot be sent, likely because 90.Xr syslogd 8 91is not running. 92.El 93.Sh SEE ALSO 94.Xr syslog_r 3 , 95.Xr syslogd 8 96.Sh HISTORY 97The 98.Fn sendsyslog 99function call appeared in 100.Ox 5.6 . 101The 102.Fa flags 103argument was added in 104.Ox 6.0 . 105