objective c - OSX: Get Session ID of PID -




is there way read session id process running in using pid?

i can current session id process using

std::string get_current_console_user() {     cfstringref result;      scdynamicstorecontext context;     scdynamicstoreref store;      context = {0, null, null, null, null};     store = scdynamicstorecreate(null, cfstr("com.apple.dts.consoleuser"), nil, &context);      result = scdynamicstorecopyconsoleuser(store, null, null);     if (result != null && !cfequal(result, cfstr("loginwindow")))     {         return std::string([(__bridge nsstring *)result utf8string]);     }     return ""; }  uint32_t get_current_login_session() {     osstatus error;     securitysessionid session_id;     sessionattributebits session_info;     if (get_current_console_user().empty())     {         return 0;     }     error = sessiongetinfo(callersecuritysession, &session_id, &session_info);     return (uint32_t)session_id; } 

is there way other processes well?





wiki

Comments

Popular posts from this blog

elasticsearch - what is the equivalent data type for geo_point in hibernate search? -

Jenkins: find build number for git commit -

firebase - How to wait value in Ionic 2 -