Title |
Phrelay and inetd in QNX4 |
Ref. No. |
QNX.000009860 |
Category(ies) |
Development |
Issue |
Is it possible to run phrelay in daemon mode?
We are using inetd to launch phrelay. Slinger is started in the sysinit, so phrelay is the only service that inetd is providing.
|
Solution |
No, unfortunately it is impossible to run phrelay in daemon mode.
You could write your own tiny inetd that does nothing but listen on the phrelay socket, and launch phrelay. Below is a slab of debug code taken from current version of phrelay that does this.
-------------code--------------- x09int sock, on, len, msgsock; x09struct sockaddr_in saddr, peername; x09garry_opt = 0; x09if((sock = socket(AF_INET, SOCK_STREAM, 0))<0) x09x09exit(1); x09setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char*) &on, sizeof(on)); x09saddr.sin_family = AF_INET; x09saddr.sin_addr.s_addr = INADDR_ANY; #define PHRELAY_PORT 4869 x09saddr.sin_port = htons(PHRELAY_PORT); x09if(bind(sock, (struct sockaddr *)&saddr, sizeof(saddr))< 0) x09x09exit(1); x09if(listen(sock, 5) < 0) x09x09exit(1); x09len = sizeof(peername); x09if((msgsock = accept(sock, (struct sockaddr *)&peername, &len))< 0) x09x09exit(1); x09close(sock); x09setsockopt(msgsock, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof(on)); x09dup2(msgsock, 0); x09dup2(msgsock, 1);
------------snippet ends--------------
Note: instead of the dup, you would want to set msgsock as stdin, stdout and exec phrelay. |
|