@@ -978,8 +978,11 @@ typedef struct RunContext {
978978 PTYForward * forward ;
979979 sd_bus_slot * match ;
980980
981- /* The exit data of the unit */
981+ /* Current state of the unit */
982982 char * active_state ;
983+ bool has_job ;
984+
985+ /* The exit data of the unit */
983986 uint64_t inactive_exit_usec ;
984987 uint64_t inactive_enter_usec ;
985988 char * result ;
@@ -1010,7 +1013,7 @@ static void run_context_check_done(RunContext *c) {
10101013 assert (c );
10111014
10121015 if (c -> match )
1013- done = STRPTR_IN_SET (c -> active_state , "inactive" , "failed" );
1016+ done = STRPTR_IN_SET (c -> active_state , "inactive" , "failed" ) && ! c -> has_job ;
10141017 else
10151018 done = true;
10161019
@@ -1021,20 +1024,35 @@ static void run_context_check_done(RunContext *c) {
10211024 sd_event_exit (c -> event , EXIT_SUCCESS );
10221025}
10231026
1027+ static int map_job (sd_bus * bus , const char * member , sd_bus_message * m , sd_bus_error * error , void * userdata ) {
1028+ bool * b = userdata ;
1029+ const char * job ;
1030+ uint32_t id ;
1031+ int r ;
1032+
1033+ r = sd_bus_message_read (m , "(uo)" , & id , & job );
1034+ if (r < 0 )
1035+ return r ;
1036+
1037+ * b = id != 0 || !streq (job , "/" );
1038+ return 0 ;
1039+ }
1040+
10241041static int run_context_update (RunContext * c , const char * path ) {
10251042
10261043 static const struct bus_properties_map map [] = {
1027- { "ActiveState" , "s" , NULL , offsetof(RunContext , active_state ) },
1028- { "InactiveExitTimestampMonotonic" , "t" , NULL , offsetof(RunContext , inactive_exit_usec ) },
1029- { "InactiveEnterTimestampMonotonic" , "t" , NULL , offsetof(RunContext , inactive_enter_usec ) },
1030- { "Result" , "s" , NULL , offsetof(RunContext , result ) },
1031- { "ExecMainCode" , "i" , NULL , offsetof(RunContext , exit_code ) },
1032- { "ExecMainStatus" , "i" , NULL , offsetof(RunContext , exit_status ) },
1033- { "CPUUsageNSec" , "t" , NULL , offsetof(RunContext , cpu_usage_nsec ) },
1034- { "IPIngressBytes" , "t" , NULL , offsetof(RunContext , ip_ingress_bytes ) },
1035- { "IPEgressBytes" , "t" , NULL , offsetof(RunContext , ip_egress_bytes ) },
1036- { "IOReadBytes" , "t" , NULL , offsetof(RunContext , io_read_bytes ) },
1037- { "IOWriteBytes" , "t" , NULL , offsetof(RunContext , io_write_bytes ) },
1044+ { "ActiveState" , "s" , NULL , offsetof(RunContext , active_state ) },
1045+ { "InactiveExitTimestampMonotonic" , "t" , NULL , offsetof(RunContext , inactive_exit_usec ) },
1046+ { "InactiveEnterTimestampMonotonic" , "t" , NULL , offsetof(RunContext , inactive_enter_usec ) },
1047+ { "Result" , "s" , NULL , offsetof(RunContext , result ) },
1048+ { "ExecMainCode" , "i" , NULL , offsetof(RunContext , exit_code ) },
1049+ { "ExecMainStatus" , "i" , NULL , offsetof(RunContext , exit_status ) },
1050+ { "CPUUsageNSec" , "t" , NULL , offsetof(RunContext , cpu_usage_nsec ) },
1051+ { "IPIngressBytes" , "t" , NULL , offsetof(RunContext , ip_ingress_bytes ) },
1052+ { "IPEgressBytes" , "t" , NULL , offsetof(RunContext , ip_egress_bytes ) },
1053+ { "IOReadBytes" , "t" , NULL , offsetof(RunContext , io_read_bytes ) },
1054+ { "IOWriteBytes" , "t" , NULL , offsetof(RunContext , io_write_bytes ) },
1055+ { "Job" , "(uo)" , map_job , offsetof(RunContext , has_job ) },
10381056 {}
10391057 };
10401058
0 commit comments