1 /*
2  * sig_bus.c
3  * (C)2001-2011 by Marc Huber <Marc.Huber@web.de>
4  * All rights reserved.
5  *
6  * $Id: sig_bus.c,v 1.10 2015/03/14 06:11:27 marc Exp marc $
7  *
8  */
9 
10 #include "misc/sysconf.h"
11 
12 static const char rcsid[] __attribute__ ((used)) = "$Id: sig_bus.c,v 1.10 2015/03/14 06:11:27 marc Exp marc $";
13 
14 #include "headers.h"
15 
catchbus(int sig)16 static void catchbus(int sig __attribute__ ((unused)))
17 {
18     struct context *ctx;
19     if (sigbus_cur > -1 && (ctx = io_get_ctx(ctx_spawnd->io, sigbus_cur))) {
20 	logmsg("catched SIGBUS (%s)", ctx->filename);
21 	ctx->dbuf = buffer_free_all(ctx->dbuf);
22 	ctx->dbufi = buffer_free_all(ctx->dbufi);
23 	ctx->chunk_start = NULL;
24 	ctx->chunk_length = 0;
25 	ctx->remaining = 0;
26 	cleanup_file(ctx, sigbus_cur);
27 	if (ctx->dfn > -1) {
28 	    reply(ctx, MSG_451_Transfer_incomplete);
29 	    cleanup_data(ctx, ctx->dfn);
30 	}
31     }
32     signal(SIGBUS, catchbus);
33     longjmp(sigbus_jmpbuf, 1);
34 }
35 
setup_sig_bus()36 void setup_sig_bus()
37 {
38     signal(SIGBUS, catchbus);
39 }
40