summaryrefslogtreecommitdiffstats
path: root/runtime/stpd/librelay.c
diff options
context:
space:
mode:
authorhunt <hunt>2006-02-25 09:41:53 +0000
committerhunt <hunt>2006-02-25 09:41:53 +0000
commit16c6a28c4d17feda8acc4c52b010968a6719a66f (patch)
tree4bc7064b05b78f70e26aec048c525507ba9d5056 /runtime/stpd/librelay.c
parenta1d1cb6b885078e1211030ff75b62f60e09e731e (diff)
downloadsystemtap-steved-16c6a28c4d17feda8acc4c52b010968a6719a66f.tar.gz
systemtap-steved-16c6a28c4d17feda8acc4c52b010968a6719a66f.tar.xz
systemtap-steved-16c6a28c4d17feda8acc4c52b010968a6719a66f.zip
2006-02-25 Martin Hunt <hunt@redhat.com>
* librelay.c (init_stp): Better error handling and cleanup.
Diffstat (limited to 'runtime/stpd/librelay.c')
-rw-r--r--runtime/stpd/librelay.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/runtime/stpd/librelay.c b/runtime/stpd/librelay.c
index 719f026d..0ef15acd 100644
--- a/runtime/stpd/librelay.c
+++ b/runtime/stpd/librelay.c
@@ -507,8 +507,13 @@ int init_stp(const char *relay_filebase, int print_summary)
ti.subbuf_size = 0;
ti.n_subbufs = 0;
ti.target = target_pid;
- send_request(STP_TRANSPORT_INFO, &ti, sizeof(ti));
-
+ if (send_request(STP_TRANSPORT_INFO, &ti, sizeof(ti)) < 0) {
+ fprintf(stderr, "stpd failed because TRANSPORT_INFO returned an error.\n");
+ if (target_cmd)
+ kill (target_pid, SIGKILL);
+ close(control_channel);
+ return -1;
+ }
return 0;
}
@@ -629,9 +634,7 @@ static void cleanup_and_exit (int closed)
close(control_channel);
if (!closed) {
- /* FIXME. overflow check */
- strcpy (tmpbuf, "/sbin/rmmod ");
- strcpy (tmpbuf + strlen(tmpbuf), modname);
+ snprintf(tmpbuf, sizeof(tmpbuf), "/sbin/rmmod %s", modname);
if (system(tmpbuf)) {
fprintf(stderr, "ERROR: couldn't rmmod probe module %s. No output will be written.\n",
modname);
@@ -728,6 +731,7 @@ int stp_main_loop(void)
if (rc < 0) {
close(control_channel);
fprintf(stderr, "ERROR: couldn't init relayfs, exiting\n");
+ /* FIXME. Need to cleanup properly */
exit(1);
}
} else if (outfile_name) {
@@ -735,10 +739,11 @@ int stp_main_loop(void)
if (!ofp) {
fprintf (stderr, "ERROR: couldn't open output file %s: errcode = %s\n",
outfile_name, strerror(errno));
+ /* FIXME. Need to cleanup properly */
exit(1);
}
}
- ts.pid = 0; // FIXME. not implemented yet
+ ts.pid = getpid();
send_request(STP_START, &ts, sizeof(ts));
break;
}