config.log
config.status
configure
+cov-int/
doc/Makefile
doc/Makefile.in
icons/Makefile
fclose(fp);
}
+static void
+free_proc_mounts(struct mount_list *mnt_list)
+{
+ struct mount_list *mnt_tmp, *mnt_next;
+
+ mnt_tmp = mnt_list;
+ while(mnt_tmp != NULL) {
+ mnt_next = mnt_tmp->next;
+ free(mnt_tmp->mountpoint);
+ free(mnt_tmp);
+ mnt_tmp = mnt_next;
+ }
+}
+
static int is_mountpoint(struct mount_list **mnt_list, char *arg)
{
char *p;
scan_knfsd(names_head, match_inodes, match_devices);
scan_mounts(names_head, match_inodes, match_devices);
scan_swaps(names_head, match_inodes, match_devices);
+ free_proc_mounts(mounts);
return print_matches(names_head, opts, sig_number);
}
char *command_buf;
char *command;
pid_t *pid_table, pid, self, *pid_killed;
- pid_t *pgids;
+ pid_t *pgids = NULL;
int i, j, okay, length, got_long, error;
int pids, max_pids, pids_killed;
unsigned long found;
exit (1);
}
if (!process_group)
- pgids = NULL; /* silence gcc */
- else
- {
+ {
pgids = calloc (pids, sizeof (pid_t));
if (!pgids)
{
perror ("malloc");
exit (1);
}
- }
+ }
for (i = 0; i < pids; i++)
{
pid_t id;
continue;
}
free (path);
+ int cmd_size = 128;
+ command_buf = (char *)malloc (cmd_size);
+ if (!command_buf)
+ exit (1);
while (1) {
/* look for actual command so we skip over initial "sh" if any */
char *p;
- int cmd_size = 128;
- command_buf = (char *)malloc (cmd_size);
- if (!command_buf)
- exit (1);
/* 'cmdline' has arguments separated by nulls */
for (p=command_buf; ; p++) {
break;
}
}
+ free(command_buf);
(void) fclose(file);
if (exact && !okay)
{
found_name = j;
break;
}
+ free(reglist);
+ free(name_len);
if (names && found_name==-1)
continue; /* match by process name faild */
fprintf (stderr, "%s(%d): %s\n", got_long ? command :
comm, id, strerror (errno));
}
+ free(pgids);
if (!quiet)
for (i = 0; i < names; i++)
if (!(found & (1 << i)))
}
sleep (1); /* wait a bit longer */
}
+ free(pid_killed);
+ free(pid_table);
return error;
}
/*
* prtstat.c - Print a processes stat file
*
- * Copyright (C) 2009 Craig Small
+ * Copyright (C) 2009-2014 Craig Small
* Based upon a shell script pstat by martin f. krafft <madduck@madduck.net>
*
* This program is free software; you can redistribute it and/or modify
FILE *fp;
struct proc_info *pr;
- pr = malloc(sizeof(struct proc_info));
if ( (asprintf(&pathname, "/proc/%d/stat",(int)pid)) < 0) {
perror(_("asprintf in print_stat failed.\n"));
else
fprintf(stderr, _("Unable to open stat file for pid %d (%s)\n"),(int)pid,strerror(errno));
free(pathname);
+ free(pr);
return;
}
free(pathname);
- if (fgets(buf,BUFSIZ,fp) == NULL) return;
+ if (fgets(buf,BUFSIZ,fp) == NULL) {
+ fclose(fp);
+ return;
+ }
+ fclose(fp);
bptr = strchr(buf, '(');
if (bptr == NULL) return;
bptr++;
+ pr = malloc(sizeof(struct proc_info));
sscanf(bptr,
"%a[^)]) "
"%c "
&pr->policy, &pr->blkio,
&pr->guest_time, &pr->cguest_time
);
- if (options & OPT_RAW) {
- print_raw_stat(pid, pr);
- return;
- }
- print_formated_stat(pid, pr);
-
-
+ if (options & OPT_RAW)
+ print_raw_stat(pid, pr);
+ else
+ print_formated_stat(pid, pr);
+ free(pr);
}
int main(int argc, char *argv[])
if (snprintf(path, PATH_MAX, "%s/%d/task/%d/stat", PROC_BASE, pid, tid) < 0)
perror("get_threadname: asprintf");
if ( (file = fopen(path, "r")) != NULL) {
- if (fread(readbuf, 1, BUFSIZ, file) > 0) {
+ if (fgets(readbuf, BUFSIZ, file) != NULL) {
if ((thread_comm = strchr(readbuf, '('))
&& (endcomm = strrchr(thread_comm, ')'))) {
++thread_comm;