What is the standard way that applications running on the command line communicate with the process of their daemon?
There are several ways to do this:
Dropboxes & signals
To store the "pid file" is used a lot of places containing the daemon process ID number: /var/run/<app>/<app>.pid, /var/run/<app>.pid(thanks @Adam Katz for editing) /run/<app>/<app>.pid, /run/<app>.pid(see. Askubuntu: why / var / run has been moved to / the run? ).
When the piddaemon process process is known, the command line program (which runs as a separate process) can interact with the daemon in the following ways:
- Writing something in a prepared place. This can be a regular file, a database table, or any convenient place read by the server.
- . - kill,
int kill(pid_t pid, int sig);.
: xinetd SIGHUP.
send-a-signal inotify API, . , , , , .
FIFO Pipe
- , , , - . /fifo mkfifo. , , . open() fopen(). /: Perl line-buffered $|=1, .
|, , .
- , mySQL? mysql mysql mysqld , .
mySQL socket. , . , .
UNIX- - . C Linux GNU C.
- - . C select(), , , . GNU C -
NodeJS - Javascript, - , .
"Callbacks"
, linux myapp foo bar?
. , .
myapp foo bar "Linux", Linux, , , .
, , .
( ) Linux - /bin/bash. , bash, bash. , , !
bash. :
: Socket Bash? dtmilano:
Q: , 127.0.0.1:4444, bash , . ?
A:
$exec 3 < > /dev/tcp/127.0.0.1/4444
$cat < & 3
bash , .. :
: TCP-, bash
, exec 5<>"/dev/tcp/${SERVER}/${PORT}" TCP- 5 .
bash TCP. -, Linux-. , William Pursell
bash. * nix. ksh Korn. csh C-. sh. . Wikipedia . !
30 , .
: . . chsh.
, , bash , , , . , . . , ipython, fooobar.com/questions/27471/..., python , , .