# Linker flags
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
-# aul_mods : modules (static library)
-add_library(aul_mods STATIC
- src/simple_util.c
- )
-
# aul
add_library(aul SHARED
src/pkginfo.c
src/app_group.c
src/aul_rsc_mgr.c
src/aul_sock.c
+ src/aul_proc.c
)
-TARGET_LINK_LIBRARIES(aul aul_mods ${libpkgs_LDFLAGS})
+TARGET_LINK_LIBRARIES(aul ${libpkgs_LDFLAGS})
SET_TARGET_PROPERTIES(aul PROPERTIES SOVERSION ${MAJORVER})
SET_TARGET_PROPERTIES(aul PROPERTIES VERSION ${FULLVER})
INSTALL(TARGETS aul DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
SET(APP_LAUNCHER "app_launcher")
ADD_EXECUTABLE(${APP_LAUNCHER} app_launcher.c)
SET_TARGET_PROPERTIES(${APP_LAUNCHER} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
-TARGET_LINK_LIBRARIES(${APP_LAUNCHER} aul aul_mods ${APP_LAUNCHER_DEPS_LDFLAGS} "-pie")
+TARGET_LINK_LIBRARIES(${APP_LAUNCHER} aul ${APP_LAUNCHER_DEPS_LDFLAGS} "-pie")
INSTALL(TARGETS app_launcher DESTINATION bin)
# appgroup info tool
SET(APPGROUP_INFO "appgroup_info")
ADD_EXECUTABLE(${APPGROUP_INFO} tool/app_group_info.c)
SET_TARGET_PROPERTIES(${APPGROUP_INFO} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
-TARGET_LINK_LIBRARIES(${APPGROUP_INFO} aul aul_mods ${APPGROUP_INFO_DEPS_LDFLAGS} "-pie")
+TARGET_LINK_LIBRARIES(${APPGROUP_INFO} aul ${APPGROUP_INFO_DEPS_LDFLAGS} "-pie")
INSTALL(TARGETS appgroup_info DESTINATION bin)
# pkgconfig file
# Install headers, other files
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_sock.h DESTINATION include/aul)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_proc.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_rsc_mgr.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_svc.h DESTINATION include/aul)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/aul_cmd.h DESTINATION include/aul)
--- /dev/null
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <unistd.h>
+#include <ctype.h>
+
+/*
+ * This API is only for Appfw internally.
+ */
+int aul_proc_iter_appid(int (*iterfunc)(const char *dname, const char *appid, void *priv, uid_t uid), void *priv);
+
+/*
+ * This API is only for Appfw internally.
+ */
+char *aul_proc_get_appid_bypid(int pid);
+
+/*
+ * This API is only for Appfw internally.
+ */
+uid_t aul_proc_get_usr_bypid(int pid);
#pragma once
#include <unistd.h>
-#include <sys/types.h>
+#include <dlog.h>
+#include <tzplatform_config.h>
-#define USE_ENGINE(engine) setenv("ELM_ENGINE", engine, 1);
+#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
-#define AUL_UTIL_PID -2
-
-#define MAX_PACKAGE_STR_SIZE 512
-#define MAX_PACKAGE_APP_PATH_SIZE 512
-#define MAX_RUNNING_APP_INFO 512
-
-#define GSLIST_FOREACH_SAFE(list, l, l_next) \
- for (l = list, \
- l_next = g_slist_next(l); \
- l; \
- l = l_next, \
- l_next = g_slist_next(l))
-
-int _add_app_status_info_list(char *appid, int pid, uid_t uid);
-int _update_app_status_info_list(int pid, int status, uid_t uid);
-int _remove_app_status_info_list(int pid, uid_t uid);
+#undef LOG_TAG
+#define LOG_TAG "AUL"
+#define _E(fmt, arg...) LOGE(fmt, ##arg)
+#define _D(fmt, arg...) LOGD(fmt, ##arg)
+#define _W(fmt, arg...) LOGW(fmt, ##arg)
+#define AUL_UTIL_PID -2
+#define MAX_LOCAL_BUFSZ 128
+#define MAX_PACKAGE_STR_SIZE 512
+#define MAX_PID_STR_BUFSZ 20
+#define MAX_UID_STR_BUFSZ 20
#include <pkgmgr-info.h>
#include <string.h>
#include <stdio.h>
-#include "simple_util.h"
+
+#include "aul_util.h"
#define MAX_PATH_LEN 1024
+++ /dev/null
-/*
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <unistd.h>
-#include <ctype.h>
-#include <dlog.h>
-#include <tzplatform_config.h>
-
-#define GLOBAL_USER tzplatform_getuid(TZ_SYS_GLOBALAPP_USER)
-
-#undef LOG_TAG
-#define LOG_TAG "AUL"
-
-#ifdef LAUNCHPAD_LOG
-#undef LOG_TAG
-#define LOG_TAG "AUL_PAD"
-#endif
-
-#ifdef AMD_LOG
-#undef LOG_TAG
-#define LOG_TAG "AUL_AMD"
-#endif
-
-#ifdef AGENT_LOG
-#undef LOG_TAG
-#define LOG_TAG "AUL_AGENT"
-#endif
-
-#define MAX_LOCAL_BUFSZ 128
-#define MAX_PID_STR_BUFSZ 20
-#define MAX_UID_STR_BUFSZ 20
-
-#define _E(fmt, arg...) LOGE(fmt, ##arg)
-#define _D(fmt, arg...) LOGD(fmt, ##arg)
-#define _W(fmt, arg...) LOGW(fmt, ##arg)
-
-#define retvm_if(expr, val, fmt, arg...) do { \
- if (expr) { \
- _E(fmt, ##arg); \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
-#define retv_if(expr, val) do { \
- if (expr) { \
- _E("(%s) -> %s() return", #expr, __FUNCTION__); \
- return (val); \
- } \
-} while (0)
-
-int __proc_iter_appid(int (*iterfunc)
- (const char *dname, const char *appid, void *priv, uid_t uid),
- void *priv);
-int __proc_iter_pgid(int pgid, int (*iterfunc) (int pid, void *priv, uid_t uid),
- void *priv);
-char *__proc_get_appid_bypid(int pid);
-char *__proc_get_cmdline_bypid(int pid);
-char *__proc_get_exe_bypid(int pid);
-uid_t __proc_get_usr_bypid(int pid);
-
-static inline const char *FILENAME(const char *filename)
-{
- const char *p;
- const char *r;
-
- if (!filename)
- return NULL;
-
- r = p = filename;
- while (*p) {
- if (*p == '/')
- r = p + 1;
- p++;
- }
-
- return r;
-}
-
-
#include "aul_util.h"
#include "aul_sock.h"
#include "launch.h"
-#include "simple_util.h"
API int aul_app_group_get_window(int pid)
{
#include "app_signal.h"
#include "aul_api.h"
-#include "simple_util.h"
+#include "aul_util.h"
#include "aul.h"
static int (*_app_dead_handler) (int pid, void *data);
#include "aul_api.h"
#include "aul_util.h"
-#include "simple_util.h"
#include "aul.h"
#define ROOT_UID 0
--- /dev/null
+/*
+ * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define _GNU_SOURCE
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "aul_api.h"
+#include "aul_proc.h"
+#include "aul_util.h"
+
+#define MAX_CMD_BUFSZ 1024
+#define APP_LABEL_PREFIX "User::App::"
+
+static int __read_proc(const char *path, char *buf, int size)
+{
+ int fd;
+ int ret;
+
+ if (buf == NULL || path == NULL)
+ return -1;
+
+ fd = open(path, O_RDONLY);
+ if (fd < 0)
+ return -1;
+
+ ret = read(fd, buf, size - 1);
+ if (ret <= 0) {
+ close(fd);
+ return -1;
+ } else
+ buf[ret] = 0;
+
+ close(fd);
+
+ return ret;
+}
+
+static int __find_pid_by_appid(const char *dname, const char *appid,
+ void *priv, uid_t uid)
+{
+ int pid = 0;
+
+ if (appid && priv
+ && strncmp(appid, (char *)priv, MAX_LOCAL_BUFSZ-1) == 0) {
+ pid = atoi(dname);
+ if (pid != getpgid(pid))
+ pid = 0;
+ }
+
+ return pid;
+}
+
+API int aul_proc_iter_appid(int (*iterfunc)(const char *dname, const char *appid, void *priv, uid_t uid), void *priv)
+{
+ DIR *dp;
+ struct dirent *dentry;
+ int pid;
+ int ret;
+ char buf[MAX_LOCAL_BUFSZ];
+ char *p;
+ uid_t uid;
+
+ dp = opendir("/proc");
+ if (dp == NULL)
+ return -1;
+
+ if (iterfunc == NULL)
+ iterfunc = __find_pid_by_appid;
+
+ while ((dentry = readdir(dp)) != NULL) {
+ if (!isdigit(dentry->d_name[0]))
+ continue;
+
+ uid = aul_proc_get_usr_bypid(atoi(dentry->d_name));
+
+ snprintf(buf, sizeof(buf), "/proc/%s/attr/current", dentry->d_name);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ continue;
+
+ p = strstr(buf, APP_LABEL_PREFIX);
+ /* not an app */
+ if (p == NULL)
+ continue;
+ p = p + strlen(APP_LABEL_PREFIX);
+ pid = iterfunc(dentry->d_name, p, priv, uid);
+
+ if (pid > 0) {
+ closedir(dp);
+ return pid;
+ }
+ }
+
+ closedir(dp);
+ return -1;
+}
+
+API uid_t aul_proc_get_usr_bypid(int pid)
+{
+ char buf[MAX_CMD_BUFSZ];
+ int ret;
+ uid_t uid;
+ struct stat DirStat;
+
+ snprintf(buf, sizeof(buf), "/proc/%d", pid);
+ ret = stat(buf, &DirStat);
+ if (ret < 0)
+ uid = (uid_t)-1;
+ else
+ uid = DirStat.st_uid;
+
+ return uid;
+}
+
+API char *aul_proc_get_appid_bypid(int pid)
+{
+ char buf[MAX_CMD_BUFSZ];
+ char *p;
+ int ret;
+
+ snprintf(buf, sizeof(buf), "/proc/%d/attr/current", pid);
+ ret = __read_proc(buf, buf, sizeof(buf));
+ if (ret <= 0)
+ return NULL;
+
+ p = strstr(buf, APP_LABEL_PREFIX);
+ /* not an app */
+ if (p == NULL)
+ return NULL;
+
+ p = p + strlen(APP_LABEL_PREFIX);
+
+ return strdup(p);
+}
#include "aul_api.h"
#include "aul_sock.h"
-#include "simple_util.h"
+#include "aul_util.h"
#define MAX_NR_OF_DESCRIPTORS 2
#include "aul.h"
#include "aul_api.h"
#include "menu_db_util.h"
-#include "simple_util.h"
#include "aul_sock.h"
#include "aul_util.h"
#include "launch.h"
#include "aul_api.h"
#include "aul_sock.h"
#include "perf.h"
-#include "simple_util.h"
+#include "aul_util.h"
#include "launch.h"
#include "key.h"
-#include "aul_util.h"
#include "app_signal.h"
#define TEP_ISMOUNT_MAX_RETRY_CNT 20
#include <poll.h>
#include <bundle.h>
#include <bundle_internal.h>
+
#include "aul.h"
#include "aul_api.h"
+#include "aul_util.h"
#include "launch.h"
-#include "simple_util.h"
static GSource *src;
#include "aul.h"
#include "aul_api.h"
#include "aul_sock.h"
-#include "simple_util.h"
-#include "launch.h"
#include "aul_util.h"
+#include "launch.h"
/*#define ACTIVATE_PREEMPT_FEATURE*/
#include "aul_api.h"
#include "miregex.h"
#include "menu_db_util.h"
-#include "simple_util.h"
+#include "aul_util.h"
static int __match_content_with_regex(const char *content, regex_t *regex_preg)
{
*/
#define _GNU_SOURCE
-#include "miregex.h"
-#include "simple_util.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
+#include "miregex.h"
+#include "aul_util.h"
+
#define MIREGEX_DIR SHARE_PREFIX"/miregex"
#define ONELINE_BUF 1024
#include "aul.h"
#include "aul_api.h"
#include "menu_db_util.h"
-#include "simple_util.h"
#include "aul_sock.h"
#include "aul_util.h"
+#include "aul_proc.h"
typedef struct _internal_param_t {
aul_app_info_iter_fn enum_fn;
char *result;
app_info_from_db *menu_info;
uid_t uid;
- result = __proc_get_appid_bypid(pid);
+ result = aul_proc_get_appid_bypid(pid);
if (result == NULL)
return -1;
- uid = __proc_get_usr_bypid(pid);
+ uid = aul_proc_get_usr_bypid(pid);
if ((menu_info = _get_app_info_from_db_by_appid_user(result, uid)) == NULL) {
free(result);
{
char *result;
- result = __proc_get_appid_bypid(pid);
+ result = aul_proc_get_appid_bypid(pid);
if (result == NULL)
return -1;
#include <dlfcn.h>
#include <iniparser.h>
#include <pkgmgr-info.h>
+
#include "aul.h"
#include "aul_api.h"
#include "aul_svc.h"
#include "aul_sock.h"
#include "aul_svc_db.h"
-#include "simple_util.h"
+#include "aul_util.h"
#include "aul_svc_priv_key.h"
#include "launch.h"
#include <tzplatform_config.h>
#include "aul_svc_db.h"
-#include "simple_util.h"
+#include "aul_util.h"
#define APP_INFO_DB_PATH tzplatform_mkpath(TZ_SYS_DB, ".pkgmgr_parser.db")
+++ /dev/null
-/*
- * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define _GNU_SOURCE
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dirent.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "simple_util.h"
-
-#define BINSH_NAME "/bin/sh"
-#define BINSH_SIZE 7
-#define VALGRIND_NAME "/home/developer/sdk_tools/valgrind/usr/bin/valgrind"
-#define VALGRIND_SIZE 51
-#define BASH_NAME "/bin/bash"
-#define BASH_SIZE 9
-#define OPROFILE_NAME "/usr/bin/oprofile_command"
-#define OPROFILE_SIZE 25
-#define OPTION_VALGRIND_NAME "valgrind"
-#define OPTION_VALGRIND_SIZE 8
-
-#define PROC_STAT_GID_POS 5
-
-#define MAX_CMD_BUFSZ 1024
-#define APP_LABEL_PREFIX "User::App::"
-
-static inline int __read_proc(const char *path, char *buf, int size);
-static inline int __find_pid_by_appid(const char *dname, const char *appid,
- void *priv, uid_t uid);
-static inline int __get_pgid_from_stat(int pid);
-
-
-static inline int __read_proc(const char *path, char *buf, int size)
-{
- int fd;
- int ret;
-
- if (buf == NULL || path == NULL)
- return -1;
-
- fd = open(path, O_RDONLY);
- if (fd < 0)
- return -1;
-
- ret = read(fd, buf, size - 1);
- if (ret <= 0) {
- close(fd);
- return -1;
- } else
- buf[ret] = 0;
-
- close(fd);
-
- return ret;
-}
-
-static inline int __find_pid_by_appid(const char *dname, const char *appid,
- void *priv, uid_t uid)
-{
- int pid = 0;
-
- if (strncmp(appid, (char *)priv, MAX_LOCAL_BUFSZ-1) == 0) {
- pid = atoi(dname);
- if (pid != getpgid(pid))
- pid = 0;
- }
-
- return pid;
-}
-
-int __proc_iter_appid(
- int (*iterfunc)(const char *dname, const char *appid, void *priv, uid_t uid),
- void *priv)
-{
- DIR *dp;
- struct dirent *dentry;
- int pid;
- int ret;
- char buf[MAX_LOCAL_BUFSZ];
- char *p;
- uid_t uid;
-
- dp = opendir("/proc");
- if (dp == NULL)
- return -1;
-
- if (iterfunc == NULL)
- iterfunc = __find_pid_by_appid;
-
- while ((dentry = readdir(dp)) != NULL) {
- if (!isdigit(dentry->d_name[0]))
- continue;
-
- uid = __proc_get_usr_bypid(atoi(dentry->d_name));
-
- snprintf(buf, sizeof(buf), "/proc/%s/attr/current", dentry->d_name);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- continue;
-
- p = strstr(buf, APP_LABEL_PREFIX);
- /* not an app */
- if (p == NULL)
- continue;
- p = p + strlen(APP_LABEL_PREFIX);
- pid = iterfunc(dentry->d_name, p, priv, uid);
-
- if (pid > 0) {
- closedir(dp);
- return pid;
- }
- }
-
- closedir(dp);
- return -1;
-}
-
-
-uid_t __proc_get_usr_bypid(int pid)
-{
- char buf[MAX_CMD_BUFSZ];
- int ret;
- uid_t uid;
- struct stat DirStat;
- snprintf(buf, sizeof(buf), "/proc/%d", pid);
- ret = stat(buf, &DirStat);
- if (ret < 0)
- uid = (uid_t)-1;
- else
- uid = DirStat.st_uid;
- return uid;
-}
-
-char *__proc_get_appid_bypid(int pid)
-{
- char buf[MAX_CMD_BUFSZ];
- char *p;
- int ret;
-
- snprintf(buf, sizeof(buf), "/proc/%d/attr/current", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- return NULL;
-
- p = strstr(buf, APP_LABEL_PREFIX);
- /* not an app */
- if (p == NULL)
- return NULL;
-
- p = p + strlen(APP_LABEL_PREFIX);
-
- return strdup(p);
-}
-
-char *__proc_get_cmdline_bypid(int pid)
-{
- char buf[MAX_CMD_BUFSZ];
- int ret;
-
- snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret <= 0)
- return NULL;
-
- /* support app launched by shell script */
- if (strncmp(buf, BINSH_NAME, BINSH_SIZE) == 0) {
- return strdup(&buf[BINSH_SIZE + 1]);
- } else if (strncmp(buf, VALGRIND_NAME, VALGRIND_SIZE) == 0) {
- char* ptr = buf;
-
- /* buf comes with double null-terminated string */
- while (1) {
- while (*ptr)
- ptr++;
-
- ptr++;
-
- if (!(*ptr))
- break;
-
- /* ignore trailing "--" */
- if (strncmp(ptr, "-", 1) != 0)
- break;
- };
-
- return strdup(ptr);
- } else if (strncmp(buf, BASH_NAME, BASH_SIZE) == 0) {
- if (strncmp(&buf[BASH_SIZE + 1], OPROFILE_NAME, OPROFILE_SIZE) == 0) {
- if (strncmp(&buf[BASH_SIZE + OPROFILE_SIZE + 2], OPTION_VALGRIND_NAME, OPTION_VALGRIND_SIZE) == 0)
- return strdup(&buf[BASH_SIZE + OPROFILE_SIZE + OPTION_VALGRIND_SIZE + 3]);
- }
- }
-
- return strdup(buf);
-}
-
-char *__proc_get_exe_bypid(int pid)
-{
- char buf[MAX_CMD_BUFSZ];
- char buf2[MAX_CMD_BUFSZ];
- ssize_t len;
-
- snprintf(buf, sizeof(buf), "/proc/%d/exe", pid);
- len = readlink(buf, buf2, MAX_CMD_BUFSZ - 1);
- if (len <= 0)
- return NULL;
- buf2[len] = 0;
- return strdup(buf2);
-}
-
-static inline int __get_pgid_from_stat(int pid)
-{
- char buf[MAX_LOCAL_BUFSZ];
- char *str = NULL;
- int ret;
- int i;
- int count = 0;
-
- if (pid <= 1)
- return -1;
-
- snprintf(buf, sizeof(buf), "/proc/%d/stat", pid);
- ret = __read_proc(buf, buf, sizeof(buf));
- if (ret < 0)
- return -1;
-
- for (i = 0; i < (ret - 1); i++) {
- if (buf[i] == ' ') {
- count++;
- if (count == PROC_STAT_GID_POS - 1)
- str = &(buf[i + 1]);
- else if (count == PROC_STAT_GID_POS) {
- buf[i] = 0;
- break;
- }
- }
- }
-
- if (count == PROC_STAT_GID_POS && str != NULL)
- pid = atoi(str);
- else
- pid = -1;
-
- return pid;
-}
-
-int __proc_iter_pgid(int pgid, int (*iterfunc)(int pid, void *priv, uid_t uid),
- void *priv)
-{
- DIR *dp;
- struct dirent *dentry;
- int _pgid;
- int ret = -1;
- uid_t uid;
-
- dp = opendir("/proc");
- if (dp == NULL)
- return -1;
-
- while ((dentry = readdir(dp)) != NULL) {
- if (!isdigit(dentry->d_name[0]))
- continue;
-
- _pgid = __get_pgid_from_stat(atoi(dentry->d_name));
- if (pgid == _pgid) {
- uid = __proc_get_usr_bypid(atoi(dentry->d_name));
- ret = iterfunc(atoi(dentry->d_name), priv, uid);
- if (ret >= 0)
- break;
- }
- }
-
- closedir(dp);
- return ret;
-}
-