mailing list of musl libc
 help / color / mirror / Atom feed
* [musl] Why connect() in syslog?
@ 2020-11-06 19:30 Markus Wichmann
  2020-11-06 21:44 ` Rich Felker
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Wichmann @ 2020-11-06 19:30 UTC (permalink / raw)
  To: musl

Hi all,

I was reading musl's syslog source code today for unrelated reasons, and
saw that it is using connect() to set the destination. And it has some
code to deal with connection failures. But why? I see the syslog socket
is a datagram socket, so I thought sendto() with destination address
means the same thing as connect() and send(), with the difference that
it is one less syscall that can fail and no connection errors to handle.
I tried finding information about the semantics of connect() on a UNIX
datagram socket, but failed to find anything useful.

Ciao,
Markus

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] Why connect() in syslog?
  2020-11-06 19:30 [musl] Why connect() in syslog? Markus Wichmann
@ 2020-11-06 21:44 ` Rich Felker
  0 siblings, 0 replies; 2+ messages in thread
From: Rich Felker @ 2020-11-06 21:44 UTC (permalink / raw)
  To: musl

On Fri, Nov 06, 2020 at 08:30:50PM +0100, Markus Wichmann wrote:
> Hi all,
> 
> I was reading musl's syslog source code today for unrelated reasons, and
> saw that it is using connect() to set the destination. And it has some
> code to deal with connection failures. But why? I see the syslog socket
> is a datagram socket, so I thought sendto() with destination address
> means the same thing as connect() and send(), with the difference that
> it is one less syscall that can fail and no connection errors to handle.
> I tried finding information about the semantics of connect() on a UNIX
> datagram socket, but failed to find anything useful.

It's there so the process can chroot, move into a namespace/container,
etc. after calling openlog without losing the ability to do logging.

Rich

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-06 21:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 19:30 [musl] Why connect() in syslog? Markus Wichmann
2020-11-06 21:44 ` Rich Felker

mailing list of musl libc

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/musl

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 musl musl/ http://inbox.vuxu.org/musl \
		musl@inbox.vuxu.org
	public-inbox-index musl

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


code repositories for the project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git