aboutsummaryrefslogtreecommitdiff
path: root/ltrace.c
diff options
context:
space:
mode:
authorIan Wienand <ianw@ieee.org>2006-02-16 06:00:00 +0100
committerIan Wienand <ianw@debian.org>2006-02-16 06:00:00 +0100
commit3219f320604810532a4938dda8f9dfadb0e840f3 (patch)
treef2430182cafc250b2fcb9eb5c05730b2ce0d802f /ltrace.c
parente1dd50cdd23a11bf7be6c81b3a2acbe35f19fdea (diff)
downloadltrace-3219f320604810532a4938dda8f9dfadb0e840f3.tar.gz
Some fixes...
* read_config_file.c: initialise pt stack argument to stop warning * summary.c: make show_summary() obey -C for demangaling function names
Diffstat (limited to 'ltrace.c')
-rw-r--r--ltrace.c86
1 files changed, 43 insertions, 43 deletions
diff --git a/ltrace.c b/ltrace.c
index 4a51f8f..0e60839 100644
--- a/ltrace.c
+++ b/ltrace.c
@@ -22,19 +22,19 @@
#define SYSCONFDIR "/etc"
#endif
-char * command = NULL;
-struct process * list_of_processes = NULL;
+char *command = NULL;
+struct process *list_of_processes = NULL;
-int exiting=0; /* =1 if a SIGINT or SIGTERM has been received */
+int exiting = 0; /* =1 if a SIGINT or SIGTERM has been received */
-static void
-signal_alarm(int sig) {
- struct process * tmp = list_of_processes;
+static void signal_alarm(int sig)
+{
+ struct process *tmp = list_of_processes;
- signal(SIGALRM,SIG_DFL);
- while(tmp) {
- struct opt_p_t * tmp2 = opt_p;
- while(tmp2) {
+ signal(SIGALRM, SIG_DFL);
+ while (tmp) {
+ struct opt_p_t *tmp2 = opt_p;
+ while (tmp2) {
if (tmp->pid == tmp2->pid) {
tmp = tmp->next;
if (!tmp) {
@@ -44,23 +44,23 @@ signal_alarm(int sig) {
}
tmp2 = tmp2->next;
}
- debug(2,"Sending SIGSTOP to process %u\n",tmp->pid);
+ debug(2, "Sending SIGSTOP to process %u\n", tmp->pid);
kill(tmp->pid, SIGSTOP);
tmp = tmp->next;
}
}
-static void
-signal_exit(int sig) {
- exiting=1;
- debug(1,"Received interrupt signal; exiting...");
- signal(SIGINT,SIG_IGN);
- signal(SIGTERM,SIG_IGN);
- signal(SIGALRM,signal_alarm);
+static void signal_exit(int sig)
+{
+ exiting = 1;
+ debug(1, "Received interrupt signal; exiting...");
+ signal(SIGINT, SIG_IGN);
+ signal(SIGTERM, SIG_IGN);
+ signal(SIGALRM, signal_alarm);
if (opt_p) {
- struct opt_p_t * tmp = opt_p;
- while(tmp) {
- debug(2,"Sending SIGSTOP to process %u\n",tmp->pid);
+ struct opt_p_t *tmp = opt_p;
+ while (tmp) {
+ debug(2, "Sending SIGSTOP to process %u\n", tmp->pid);
kill(tmp->pid, SIGSTOP);
tmp = tmp->next;
}
@@ -68,41 +68,41 @@ signal_exit(int sig) {
alarm(1);
}
-static void
-normal_exit(void) {
- output_line(0,0);
+static void normal_exit(void)
+{
+ output_line(0, 0);
if (opt_c) {
show_summary();
}
}
-static void
-guess_cols(void) {
+static void guess_cols(void)
+{
struct winsize ws;
- char * c;
+ char *c;
opt_a = DEFAULT_ACOLUMN;
c = getenv("COLUMNS");
if (c && *c) {
- char * endptr;
+ char *endptr;
int cols;
cols = strtol(c, &endptr, 0);
- if (cols>0 && !*endptr) {
- opt_a = cols * 5/8;
+ if (cols > 0 && !*endptr) {
+ opt_a = cols * 5 / 8;
}
- } else if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col>0) {
- opt_a = ws.ws_col * 5/8;
+ } else if (ioctl(1, TIOCGWINSZ, &ws) != -1 && ws.ws_col > 0) {
+ opt_a = ws.ws_col * 5 / 8;
}
}
-int
-main(int argc, char **argv) {
- struct opt_p_t * opt_p_tmp;
- char * home;
+int main(int argc, char **argv)
+{
+ struct opt_p_t *opt_p_tmp;
+ char *home;
atexit(normal_exit);
- signal(SIGINT,signal_exit); /* Detach processes when interrupted */
- signal(SIGTERM,signal_exit); /* ... or killed */
+ signal(SIGINT, signal_exit); /* Detach processes when interrupted */
+ signal(SIGTERM, signal_exit); /* ... or killed */
guess_cols();
argv = process_options(argc, argv);
@@ -110,7 +110,7 @@ main(int argc, char **argv) {
home = getenv("HOME");
if (home) {
char path[PATH_MAX];
- if (strlen(home) > PATH_MAX-15) {
+ if (strlen(home) > PATH_MAX - 15) {
fprintf(stderr, "Error: $HOME too long\n");
exit(1);
}
@@ -119,9 +119,9 @@ main(int argc, char **argv) {
read_config_file(path);
}
if (opt_e) {
- struct opt_e_t * tmp = opt_e;
- while(tmp) {
- debug(1,"Option -e: %s\n", tmp->name);
+ struct opt_e_t *tmp = opt_e;
+ while (tmp) {
+ debug(1, "Option -e: %s\n", tmp->name);
tmp = tmp->next;
}
}
@@ -133,7 +133,7 @@ main(int argc, char **argv) {
open_pid(opt_p_tmp->pid, 1);
opt_p_tmp = opt_p_tmp->next;
}
- while(1) {
+ while (1) {
process_event(wait_for_something());
}
}