github.com/256dpi/max-go@v0.7.0/lib/max/ext_sysprocess.h (about) 1 #ifndef _EXT_SYSPROCESS_H_ 2 #define _EXT_SYSPROCESS_H_ 3 4 #include "ext_prefix.h" 5 #include "ext_mess.h" 6 7 BEGIN_USING_C_LINKAGE 8 9 enum { 10 SYSPROCESS_LAUNCHFLAGS_NONE = 0, 11 SYSPROCESS_LAUNCHFLAGS_NOWINDOW = 0x01, 12 SYSPROCESS_LAUNCHFLAGS_NOWINDOW_ALLOWDIALOGS = 0x02 13 }; 14 15 // returns process id or 0 on error 16 long sysprocess_launch(const char *utf8path, const char *utf8commandline); 17 18 // returns process id or 0 on error 19 long sysprocess_launch_withflags(const char *utf8path, const char *utf8commandline, long flags); 20 21 // returns non-zero if process is still running 22 long sysprocess_isrunning(long id); 23 24 // returns non-zero if process is still running, optional non-running process return value in 'retval' argument 25 // note that return value will only work reliably the first time the function is called on a terminated process 26 long sysprocess_isrunning_with_returnvalue(long id, long *retval); 27 28 // kill a running process (SIGKILL), returns 0 if successful 29 long sysprocess_kill(long id); 30 31 // returns 0 if successful 32 long sysprocess_activate(long id); 33 34 // returns 0 if process isn't running 35 long sysprocess_getid(const char *utf8path); // find the process id for a given app 36 37 // returns the id of the currently running process 38 long sysprocess_getcurrentid(void); 39 40 // given process ID returns path as utf8 string 41 // note: you must free the returned memory with sysmem_freeptr() 42 long sysprocess_getpath(long id, char **utf8path); 43 44 // sysprocesswatcher: monitors process with given id and if process quits calls given method with arg. 45 // note: method is called on a separate thread so you can possibly free a stalled main thread. 46 // If you are done then free the sysprocesswatcher with object_free() and the monitoring thread will be killed. 47 t_object* sysprocesswatcher_new(long id, method m, void *arg); 48 49 // determines if the architecture of the named process (x64 or i386) fits the current one 50 long sysprocess_fitsarch(long id); 51 52 END_USING_C_LINKAGE 53 54 #endif // _EXT_SYSPROCESS_H_