#include "opensrf/transport_client.h"
+#include "signal.h"
-/**
- * Simple jabber client
- */
-
-
+pid_t pid;
+void sig_int( int sig ) {
+ fprintf(stderr, "Killing child %d\n", pid );
+ kill( pid, SIGKILL );
+}
/* connects and registers with the router */
int main( int argc, char** argv ) {
else
fatal_handler( "NOT Connected...\n" );
- if( fork() ) {
+ if( (pid=fork()) ) { /* parent */
+ signal(SIGINT, sig_int);
fprintf(stderr, "Listener: %d\n", getpid() );
char buf[300];
memset(buf, 0, 300);
printf("\n=> ");
memset(buf, 0, 300);
}
+ fprintf(stderr, "Killing child %d\n", pid );
+ kill( pid, SIGKILL );
return 0;
} else {
while( (recv=client_recv( client, -1)) ) {
if( recv->is_error )
fprintf( stderr, "\nReceived Error\t: ------------------\nFrom:\t\t"
- "%s\nRouterFrom:\t%s\nBody:\t\t%s\nType %s\nCode %d\n=> ", recv->sender, recv->router_from, recv->body, recv->error_type, recv->error_code );
+ "%s\nRouterFrom:\t%s\nBody:\t\t%s\nType %s\nCode %d\n=> ",
+ recv->sender, recv->router_from, recv->body, recv->error_type, recv->error_code );
else
fprintf( stderr, "\nReceived\t: ------------------\nFrom:\t\t"
"%s\nRouterFrom:\t%s\nBody:\t\t%s\n=> ", recv->sender, recv->router_from, recv->body );