diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-06-12 23:18:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-06-12 23:18:29 +0000 |
commit | 0b10d145926240dd86c1d70ff7f91258347a0d1c (patch) | |
tree | 7aa6601a3d966448b94fb9a0076d92379305f523 /src/main/extractor.c | |
parent | f1445d85a8ade62fec54ddad1099b9ab5802cd37 (diff) | |
download | libextractor-0b10d145926240dd86c1d70ff7f91258347a0d1c.tar.gz libextractor-0b10d145926240dd86c1d70ff7f91258347a0d1c.zip |
handle strange error better
Diffstat (limited to 'src/main/extractor.c')
-rw-r--r-- | src/main/extractor.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/main/extractor.c b/src/main/extractor.c index 6e3c639..109e256 100644 --- a/src/main/extractor.c +++ b/src/main/extractor.c | |||
@@ -1398,14 +1398,15 @@ start_process (struct EXTRACTOR_PluginList *plugin) | |||
1398 | int p1[2]; | 1398 | int p1[2]; |
1399 | int p2[2]; | 1399 | int p2[2]; |
1400 | pid_t pid; | 1400 | pid_t pid; |
1401 | int status; | ||
1401 | 1402 | ||
1403 | plugin->cpid = -1; | ||
1402 | #ifndef WINDOWS | 1404 | #ifndef WINDOWS |
1403 | if (0 != pipe (p1)) | 1405 | if (0 != pipe (p1)) |
1404 | #else | 1406 | #else |
1405 | if (0 != _pipe (p1, 0, _O_BINARY)) | 1407 | if (0 != _pipe (p1, 0, _O_BINARY)) |
1406 | #endif | 1408 | #endif |
1407 | { | 1409 | { |
1408 | plugin->cpid = -1; | ||
1409 | plugin->flags = EXTRACTOR_OPTION_DISABLED; | 1410 | plugin->flags = EXTRACTOR_OPTION_DISABLED; |
1410 | return; | 1411 | return; |
1411 | } | 1412 | } |
@@ -1417,7 +1418,6 @@ start_process (struct EXTRACTOR_PluginList *plugin) | |||
1417 | { | 1418 | { |
1418 | close (p1[0]); | 1419 | close (p1[0]); |
1419 | close (p1[1]); | 1420 | close (p1[1]); |
1420 | plugin->cpid = -1; | ||
1421 | plugin->flags = EXTRACTOR_OPTION_DISABLED; | 1421 | plugin->flags = EXTRACTOR_OPTION_DISABLED; |
1422 | return; | 1422 | return; |
1423 | } | 1423 | } |
@@ -1444,14 +1444,13 @@ start_process (struct EXTRACTOR_PluginList *plugin) | |||
1444 | close (p1[1]); | 1444 | close (p1[1]); |
1445 | close (p2[0]); | 1445 | close (p2[0]); |
1446 | close (p2[1]); | 1446 | close (p2[1]); |
1447 | plugin->cpid = -1; | ||
1448 | plugin->flags = EXTRACTOR_OPTION_DISABLED; | 1447 | plugin->flags = EXTRACTOR_OPTION_DISABLED; |
1449 | return; | 1448 | return; |
1450 | } | 1449 | } |
1451 | if (pid == 0) | 1450 | if (pid == 0) |
1452 | { | 1451 | { |
1453 | close (p1[1]); | 1452 | close (p1[1]); |
1454 | close (p2[0]); | 1453 | close (p2[0]); |
1455 | process_requests (plugin, p1[0], p2[1]); | 1454 | process_requests (plugin, p1[0], p2[1]); |
1456 | _exit (0); | 1455 | _exit (0); |
1457 | } | 1456 | } |
@@ -1460,7 +1459,16 @@ start_process (struct EXTRACTOR_PluginList *plugin) | |||
1460 | close (p2[1]); | 1459 | close (p2[1]); |
1461 | plugin->cpipe_in = fdopen (p1[1], "w"); | 1460 | plugin->cpipe_in = fdopen (p1[1], "w"); |
1462 | if (plugin->cpipe_in == NULL) | 1461 | if (plugin->cpipe_in == NULL) |
1463 | perror ("fdopen"); | 1462 | { |
1463 | perror ("fdopen"); | ||
1464 | (void) kill (plugin->cpid, SIGKILL); | ||
1465 | waitpid (plugin->cpid, &status, 0); | ||
1466 | close (p1[0]); | ||
1467 | close (p2[1]); | ||
1468 | plugin->cpid = -1; | ||
1469 | plugin->flags = EXTRACTOR_OPTION_DISABLED; | ||
1470 | return; | ||
1471 | } | ||
1464 | plugin->cpipe_out = p2[0]; | 1472 | plugin->cpipe_out = p2[0]; |
1465 | } | 1473 | } |
1466 | 1474 | ||