troglobit / finit

Fast init for Linux. Cookies included
https://troglobit.com/projects/finit/
MIT License
634 stars 63 forks source link

Processes depends on notify:pid did not stop when their parent process was killed #392

Closed justbaominh closed 10 months ago

justbaominh commented 10 months ago

I've managed to run synchronization with PID and systemd. However, during my testing, I noticed an issue with the dependency management. Specifically, processes dependent on notify:pid did not stop when their parent process was killed.

Here is my configuration

# Test systemd notify
service name:test1_systemd [2345] restart:0 notify:systemd ready:/data/finit/script/ready.sh finit_test -n DEP1 --systemd -d 2 -- Systemd proc
service name:test2 [2345] <service/test1_systemd/ready> finit_test -n DEP2 -- Dependency test 1

#Test pid notify
service name:test3_pid [2345] notify:pid <service/test1_systemd/ready> ready:/data/finit/script/ready.sh finit_test -n DEP3 -d 2 -p -- Dependency test 1
service name:test4 [2345] <service/test3_pid/ready> finit_test -n DEP4 -- Dependency test 3

In this setup, test3_pid depends on test1_systemd. When I terminate test1_systemd, both test2 and test3 stop, but test4 continues running. Pid file was removed whey they exit. Here are the logs:

0    test1_systemd  restart  [---2345----] Systemd proc
0    test2          waiting  [---2345----] Dependency test 1
0    test3_pid      waiting  [---2345----] Dependency test 1
170  test4          running  [---2345----] Dependency test 3

I also tested with systemd and observed that test4 stops running when test1 is killed.

Here is my initctl cond

   PID  IDENT          STATUS  CONDITION (+ ON, ~ FLUX, - OFF)                                                                                                                    
   0    test2          off     <-service/test1_systemd/ready>
   0    test3_pid      off     <-service/test1_systemd/ready>
   170  test4          on      <+service/test3_pid/ready>

initctl cond dump

PID  IDENT          STATUS  CONDITION                                                                                                                                          
    13   syslogd        on      <pid/syslogd>
    1    init           on      <int/bootstrap>
    1    init           on      <int/container>
    1    static         on      <hook/mount/root>
    1    static         on      <hook/mount/all>
    1    static         on      <hook/svc/up>
    1    static         on      <hook/svc/plugin>
    1    static         on      <hook/net/up>
    1    static         on      <hook/sys/up>
    1    static         on      <hook/sys/banner>
    1    init           on      <service/syslogd/ready>
    1    init           on      <service/syslogd/running>
    1    init           on      <service/test1_systemd/restart>
    1    init           on      <service/test4/running>
    1    init           on      <service/mdev/ready>
    1    init           on      <service/mdev/running>
    1    init           on      <service/test3_pid/ready>
troglobit commented 10 months ago

Thank you for the write-up, much appreciated!

Assigning to v4.7

troglobit commented 10 months ago

Reproduced.

troglobit commented 10 months ago

Fixed.

Unless other issues pop up, the v4.7 release will likely be released very soon.