@@ -20,6 +20,7 @@ in the source distribution for its full text.
2020#include "CRT.h"
2121#include "Macros.h"
2222#include "Object.h"
23+ #include "ProgramLauncher.h"
2324#include "RichString.h"
2425#include "Settings.h"
2526#include "XUtils.h"
@@ -35,6 +36,8 @@ typedef struct OpenRCMeterContext {
3536static OpenRCMeterContext_t ctx_system ;
3637static OpenRCMeterContext_t ctx_user ;
3738
39+ static ProgramLauncher OpenRCMeter_programLauncher ;
40+
3841static void OpenRCMeter_done (ATTR_UNUSED Meter * this ) {
3942 OpenRCMeterContext_t * ctx = String_eq (Meter_name (this ), "OpenRCUser" ) ? & ctx_user : & ctx_system ;
4043
@@ -48,6 +51,10 @@ static void updateViaExec(bool user) {
4851 if (Settings_isReadonly ())
4952 return ;
5053
54+ ProgramLauncher_setPath (& OpenRCMeter_programLauncher , "rc-status" );
55+ if (OpenRCMeter_programLauncher .lastErrno != 0 )
56+ return ;
57+
5158 int fdpair [2 ] = {-1 , -1 };
5259 if (pipe (fdpair ) < 0 )
5360 return ;
@@ -68,11 +75,15 @@ static void updateViaExec(bool user) {
6875 exit (1 );
6976 dup2 (fdnull , STDERR_FILENO );
7077 close (fdnull );
71- if (user ) {
72- execlp ("rc-status" , "rc-status" , "--user" , "-a" , (char * )NULL );
73- } else {
74- execlp ("rc-status" , "rc-status" , "-a" , (char * )NULL );
75- }
78+
79+ const char * argv [] = {
80+ "rc-status" ,
81+ "-a" ,
82+ (user ? "--user" : NULL ),
83+ NULL
84+ };
85+ ProgramLauncher_execv_const (& OpenRCMeter_programLauncher , argv );
86+
7687 exit (127 );
7788 }
7889 close (fdpair [1 ]);
0 commit comments