The program source codes and the foobar.service , the foobar.socket are as the attachments.
Thanks for any suggestion! At 2017-12-29 16:19:35, "eshark" <eshar...@163.com> wrote: Hi, All I tried to test the socket activation by a simple foobar.socket and foobar.service, which are as the following: foobar.socket: [Socket] ListenStream=/dev/socket/foobar [Install] WantedBy=sockets.target foobar.service: [Service] Type=simple ExecStart=/usr/bin/test-socket Restart=no I also wrote a simple program to connect to /dev/socket/foobar , in order to activitate the foobar.service. When I ran the program, the foobar.service was started by systemd , and the foobar.socket changed from 'listening' state to 'running' state. All works OK as expected, but when I killed the test-socket, it was started again by the systemd, even if I didn't run my program. And from the system journal logs , I found that " Line 2035: 31,29604,571630004,-;systemd[1]: foobar.socket got notified about service death (failed permanently: no) Line 2038: 31,29605,571630065,-;systemd[1]: foobar.socket changed running -> listening Line 2050: 31,29609,571632385,-;systemd[1]: Incoming traffic on foobar.socket Line 2056: 28,29611,571633087,-;systemd[1]: Cannot add dependency job for unit systemd-bus-proxyd.socket, ignoring: Unit systemd-bus-proxyd.socket failed to load: No such file or directory. Line 2056: 28,29611,571633087,-;systemd[1]: Cannot add dependency job for unit systemd-bus-proxyd.socket, ignoring: Unit systemd-bus-proxyd.socket failed to load: No such file or directory. Line 2065: 31,29614,571633544,-;systemd[1]: foobar.socket changed listening -> running " It seems that immediately after the death of foobar.service, some unknown incoming traffic on foobar.socket made the foobar.service started again by the systemd . Could anyone give me some suggestion that who connected to the foobar.socket ? Any idea about how to debug this problem is very appreciated. Thanks a lot.
#include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <sys/un.h> #include <properties/properties.h> #define UNIX_DOMAIN "/dev/socket/foobar" #define CONTAINER_EXIT_PROP_NAME "sys.pagemanagerd.status" #define HOST_EXIT_PROP_NAME "service.bootanim.exit" int require_services(void) { int connect_fd; int ret; int i; static struct sockaddr_un srv_addr; connect_fd=socket(PF_UNIX,SOCK_STREAM,0); if(connect_fd<0) { perror("cannot create communication socket"); return 1; } srv_addr.sun_family=AF_UNIX; strcpy(srv_addr.sun_path,UNIX_DOMAIN); ret=connect(connect_fd,(struct sockaddr*)&srv_addr,sizeof(srv_addr)); if(ret==-1) { perror("cannot connect to the server"); close(connect_fd); return 0; } close(connect_fd); return 0; } int main(void) { require_services(); sleep(10); return 0; }
foobar.service
Description: Binary data
foobar.socket
Description: Binary data
_______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/systemd-devel