diff options
| author | ulteq <ulteq@web.de> | 2018-01-20 11:25:09 +0100 | 
|---|---|---|
| committer | ulteq <ulteq@web.de> | 2018-01-20 11:25:09 +0100 | 
| commit | 394517d1c66783c4e1d044f79df9ef1703a6f5db (patch) | |
| tree | b9aecd397c02021244ef092d0b5aef1f79c9c895 | |
| parent | 325839b424421a0324d9e1687e512ff63c84c540 (diff) | |
Fix the --magick-timeout handling
* Prevents nasty loading loops
* Prevents zombie subprocesses
* Fixes the conversion timeout detection routine
| -rw-r--r-- | src/imlib.c | 25 | 
1 files changed, 6 insertions, 19 deletions
| diff --git a/src/imlib.c b/src/imlib.c index 73b7039..6de6bdb 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -231,7 +231,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file)  	if ((image_source != SRC_IMLIB) && tmpname) {  		*im = imlib_load_image_with_error_return(tmpname, &err); -		if (im) { +		if (!err && im) {  			real_filename = file->filename;  			file->filename = tmpname;  			feh_file_info_load(file, *im); @@ -240,7 +240,7 @@ int feh_load_image(Imlib_Image * im, feh_file * file)  			file->ed = exif_get_data(tmpname);  #endif  		} -		if ((image_source == SRC_MAGICK) || !opt.keep_http) +		if ((image_source != SRC_HTTP) || !opt.keep_http)  			unlink(tmpname);  		free(tmpname); @@ -357,30 +357,17 @@ static char *feh_magick_load_image(char *filename)  	else {  		alarm(opt.magick_timeout);  		waitpid(childpid, &status, 0); -		alarm(0); -		if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { -			close(fd); +		kill(childpid, SIGKILL); +		if (opt.magick_timeout > 0 && !alarm(0)) {  			unlink(sfn);  			free(sfn);  			sfn = NULL;  			if (!opt.quiet) { -				if (WIFSIGNALED(status)) -					weprintf("%s - Conversion took too long, skipping", -						filename); +				weprintf("%s - Conversion took too long, skipping", filename);  			} - -			/* -			 * Reap child.  The previous waitpid call was interrupted by -			 * alarm, but convert doesn't terminate immediately. -			 * XXX -			 * normally, if (WIFSIGNALED(status)) waitpid(childpid, &status, 0); -			 * would suffice. However, as soon as feh has its own window, -			 * this doesn't work anymore and the following workaround is -			 * required. Hm. -			 */ -			waitpid(-1, &status, 0);  		} +		close(fd);  		childpid = 0;  	} | 
