MCPcopy Index your code
hub / github.com/Xfennec/progress / monitor_processes

Function monitor_processes

progress.c:935–1141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

933}
934
935int monitor_processes(int *nb_pid)
936{
937int pid_count, fd_count, result_count;
938int i,j;
939pidinfo_t pidinfo_list[MAX_PIDS];
940fdinfo_t fdinfo;
941fdinfo_t biggest_fd;
942int fdnum_list[MAX_FD_PER_PID];
943off_t max_size;
944char fsize[64];
945char fpos[64];
946char ftroughput[64];
947float perc;
948result_t results[MAX_RESULTS];
949signed char still_there;
950signed char search_all = 1;
951static signed char first_pass = 1;
952
953pid_count = 0;
954if (!flag_monitor && !flag_monitor_continuous)
955 first_pass = 0;
956
957
958if (proc_specifiq_name_cnt) {
959 search_all = 0;
960 for (i = 0 ; i < proc_specifiq_name_cnt ; ++i) {
961 pid_count += find_pids_by_binary_name(proc_specifiq_name[i],
962 pidinfo_list + pid_count,
963 MAX_PIDS - pid_count);
964 if(pid_count >= MAX_PIDS) {
965 nfprintf(stderr, "Found too much procs (max = %d)\n",MAX_PIDS);
966 return 0;
967 }
968 }
969}
970
971if (proc_specifiq_pid) {
972 search_all = 0;
973 for (i = 0 ; i < proc_specifiq_pid_cnt ; ++i) {
974 pid_count += find_pid_by_id(proc_specifiq_pid[i],
975 pidinfo_list + pid_count);
976
977 if(pid_count >= MAX_PIDS) {
978 nfprintf(stderr, "Found too much procs (max = %d)\n",MAX_PIDS);
979 return 0;
980 }
981 }
982}
983
984if (search_all) {
985 for (i = 0 ; i < proc_names_cnt ; i++) {
986 pid_count += find_pids_by_binary_name(proc_names[i],
987 pidinfo_list + pid_count,
988 MAX_PIDS - pid_count);
989 if(pid_count >= MAX_PIDS) {
990 nfprintf(stderr, "Found too much procs (max = %d)\n",MAX_PIDS);
991 return 0;
992 }

Callers 1

mainFunction · 0.85

Calls 11

find_pids_by_binary_nameFunction · 0.85
nfprintfFunction · 0.85
find_pid_by_idFunction · 0.85
find_fd_for_pidFunction · 0.85
get_fdinfoFunction · 0.85
copy_and_clean_resultsFunction · 0.85
format_sizeFunction · 0.85
nprintfFunction · 0.85
add_to_hlistFunction · 0.85
get_hlist_averageFunction · 0.85
print_etaFunction · 0.85

Tested by

no test coverage detected