D
D
DVoropaev2020-05-09 23:05:51
linux
DVoropaev, 2020-05-09 23:05:51

How to access daemon's I/O threads in linux?

My program has this structure:

def UserInterface():
    while(True):
        print("hello")
        tmp = input()
        ...

def payload():
    while(True):
        #Something code

def main():
    Thread(target=UserInterface, args=()).start()
    Thread(target=payload, args=()).start()

There are two threads running in an endless loop. The first thread is a text interface through which you can receive commands from the user and display information to him. The second stream is the "payload".
I run the program with a command from the terminal and all is well. But I want to run my program as a daemon via systemd. If I do this, how can I get the opportunity to interact with the program?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Karpion, 2020-05-10
@Karpion

The normal daemon doesn't work through stdin/stdout/stderr. You should look towards named pipe or unix socket - these are such special files. And ideally, you need to interact via TCP so that you can cling to the telnet program there (but better - with encryption, via ssh).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question