Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #162327

Re: How can a daemon process open() the stdout of someone who signals it?

From Kaz Kylheku <563-365-8930@kylheku.com>
Newsgroups comp.lang.c
Subject Re: How can a daemon process open() the stdout of someone who signals it?
Date 2021-08-11 18:10 +0000
Organization A noiseless patient Spider
Message-ID <20210811110000.589@kylheku.com> (permalink)
References <sf0kp8$ki0$1@reader1.panix.com>

Show all headers | View raw


On 2021-08-11, John Forkosh <forkosh@panix.com> wrote:
> Specifically, below's the little test program I wrote.
> It works fine, but isn't programmed to do exactly what I want
> because I can't figure out how to program that.
>
> It runs as a daemon, just sitting on a pause() until
> it catches a signal, via  killall -SIGINT testdaemon
> and then it just writes a dummy line with date/time and
> #running processes to a log file. Just a "Hello, World" test.
>
> But what I want is to write some stuff to the stdout
> of the process that sent the signal to testdaemon.

I wouldn't bang my head against the wall by doing it this way.

What you can do is implement a little management protocol for
your server that uses some inter-process communication mechanism,
like sockets.

Then write a CLI over the protocol that provides a command language
for doing things with the server.

The server can send output over the protocol, which the CLI can dump on
its standard output.

There are things you can try. In Unix, there are ways to send an open
file descriptor from one process to another. So it seems like it would
be possible to connect to the server somehow, and say "here is file
descriptor; please send printed output to it" (it happens to be my
standard output).

Ooen descriptors can be passed over Unix sockets (AF_UNIX == AF_LOCAL
address family) and SystemV streams and maybe other ways.

I don't think signal handling can pass an open descriptor, so it
couldn't literally work they way you want: get a signal from
some process, and then obtain a descriptor from it.

More like, process opens an AF_UNIX socket to the server,
and passes the desired file descriptor.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How can a daemon process open() the stdout of someone who signals it? John Forkosh <forkosh@panix.com> - 2021-08-11 13:53 +0000
  Re: How can a daemon process open() the stdout of someone who signals it? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-08-11 15:41 +0000
    Re: How can a daemon process open() the stdout of someone who signals it? John Forkosh <forkosh@panix.com> - 2021-08-12 03:11 +0000
    Re: How can a daemon process open() the stdout of someone who signals it? Vir Campestris <vir.campestris@invalid.invalid> - 2021-08-13 21:30 +0100
      Re: How can a daemon process open() the stdout of someone who signals it? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-08-14 14:25 +0000
  Re: How can a daemon process open() the stdout of someone who signals it? Kaz Kylheku <563-365-8930@kylheku.com> - 2021-08-11 18:10 +0000
    Re: How can a daemon process open() the stdout of someone who signals it? John Forkosh <forkosh@panix.com> - 2021-08-12 03:17 +0000

csiph-web