Changeset 402:98bc92448192
- Timestamp:
- 1998-10-05 23:07:55 (10 years ago)
- Author:
- Thomas Roessler <roessler@…>
- Branch:
- HEAD
- Message:
-
Fix another pipe-related hang in mutt_view_attachment().
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r300
|
r402
|
|
| 359 | 359 | tempfile, sizeof (tempfile))) |
| 360 | 360 | { |
| 361 | | if (fp == NULL) |
| | 361 | if (fp == NULL && strcmp(tempfile, a->filename)) |
| 362 | 362 | { |
| 363 | 363 | /* send case: the file is already there */ |
| … |
… |
|
| 404 | 404 | { |
| 405 | 405 | pid_t thepid = 0; |
| 406 | | FILE *pagerfp = NULL; |
| 407 | | FILE *tempfp = NULL; |
| 408 | | FILE *filter_in; |
| 409 | | FILE *filter_out; |
| 410 | | |
| | 406 | int tempfd = -1, pagerfd = -1; |
| | 407 | |
| 411 | 408 | if (!use_pager) |
| 412 | 409 | endwin (); |
| … |
… |
|
| 414 | 411 | if (use_pager || use_pipe) |
| 415 | 412 | { |
| 416 | | if (use_pager && ((pagerfp = safe_fopen (pagerfile, "w")) == NULL)) |
| 417 | | { |
| 418 | | mutt_perror ("fopen"); |
| | 413 | if (use_pager && ((pagerfd = safe_open (pagerfile, O_CREAT | O_EXCL | O_WRONLY)) == -1)) |
| | 414 | { |
| | 415 | mutt_perror ("open"); |
| 419 | 416 | goto return_error; |
| 420 | 417 | } |
| 421 | | if (use_pipe && ((tempfp = fopen (tempfile, "r")) == NULL)) |
| 422 | | { |
| 423 | | if (pagerfp) |
| 424 | | fclose (pagerfp); |
| 425 | | mutt_perror ("fopen"); |
| | 418 | if (use_pipe && ((tempfd = open (tempfile, 0)) == -1)) |
| | 419 | { |
| | 420 | if(pagerfd != -1) |
| | 421 | close(pagerfd); |
| | 422 | mutt_perror ("open"); |
| 426 | 423 | goto return_error; |
| 427 | 424 | } |
| 428 | 425 | |
| 429 | | if ((thepid = mutt_create_filter (command, use_pipe ? &filter_in : NULL, |
| 430 | | use_pager ? &filter_out : NULL, NULL)) == -1) |
| 431 | | { |
| 432 | | if (pagerfp) |
| 433 | | fclose (pagerfp); |
| 434 | | if (tempfp) |
| 435 | | fclose (tempfp); |
| | 426 | if ((thepid = mutt_create_filter_fd (command, NULL, NULL, NULL, |
| | 427 | use_pipe ? tempfd : -1, use_pager ? pagerfd : -1, -1)) == -1) |
| | 428 | { |
| | 429 | if(pagerfd != -1) |
| | 430 | close(pagerfd); |
| | 431 | |
| | 432 | if(tempfd != -1) |
| | 433 | close(tempfd); |
| | 434 | |
| 436 | 435 | mutt_error _("Cannot create filter"); |
| 437 | 436 | goto return_error; |
| 438 | 437 | } |
| 439 | 438 | |
| 440 | | if (use_pipe) |
| 441 | | { |
| 442 | | mutt_copy_stream (tempfp, filter_in); |
| 443 | | fclose (tempfp); |
| 444 | | fclose (filter_in); |
| 445 | | } |
| 446 | 439 | if (use_pager) |
| 447 | 440 | { |
| 448 | | mutt_copy_stream (filter_out, pagerfp); |
| 449 | | fclose (filter_out); |
| 450 | | fclose (pagerfp); |
| 451 | 441 | if (a->description) |
| 452 | 442 | snprintf (descrip, sizeof (descrip), |
| … |
… |
|
| 461 | 451 | option (OPTWAITKEY))) && !use_pager) |
| 462 | 452 | mutt_any_key_to_continue (NULL); |
| | 453 | |
| | 454 | close(tempfd); |
| | 455 | close(pagerfd); |
| | 456 | |
| 463 | 457 | } |
| 464 | 458 | else |