00001 #include "config.h" 00002 00003 #ifdef HAVE_UNISTD_H 00004 #include <unistd.h> 00005 #endif 00006 00007 #include <string> 00008 #include <cstring> 00009 #include <cassert> 00010 00011 #include "asserts.h" 00012 #include "error.h" 00013 #include "fs.h" 00014 #include "exec.h" 00015 #include "fdstream.h" 00016 00017 // static char confdir[4096] = { 0 }; 00018 00019 /* 00020 void test1(void) 00021 { 00022 execute exe; 00023 bool thrown = false; 00024 00025 try { 00026 exe.fork(); 00027 } 00028 catch (error &e) { 00029 thrown = true; 00030 } 00031 assert(!thrown); 00032 exe.wait(); 00033 if (exe.is_child()) exe.exit(0); 00034 } 00035 */ 00036 00037 /* 00038 void test2(void) 00039 { 00040 execute exe; 00041 00042 exe.fork(); 00043 if (exe.is_parent()) { 00044 char *msg_to_child = "Message from parent"; 00045 char msg_from_child[4096] = { 0 }; 00046 char msg_from_err[4096] = { 0 }; 00047 00048 assert(exe.child_running()); 00049 assert(!exe.child_exited()); 00050 assert(!exe.child_exited_normally()); 00051 assert(!exe.child_signaled()); 00052 assert(exe.child_exit_code() == 0); 00053 assert(exe.child_signal_no() == 0); 00054 00055 if (write(exe.in_fd(), msg_to_child, strlen(msg_to_child)) 00056 != (int)strlen(msg_to_child)) 00057 throw(ERROR(errno,"Error writing to child's input pipe")); 00058 if (read(exe.out_fd(), msg_from_child, 4096) == 0) 00059 throw(ERROR(errno,"Error reading from child's output pipe")); 00060 if (read(exe.err_fd(), msg_from_err, 4096) == 0) 00061 throw(ERROR(errno,"Error reading from child's error pipe")); 00062 00063 exe.wait(); 00064 00065 assert(static_cast<std::string>(msg_from_child) == "Message from child"); 00066 assert(static_cast<std::string>(msg_from_err) == "Message from child err"); 00067 assert(!exe.child_running()); 00068 assert(exe.child_exited()); 00069 assert(exe.child_exited_normally()); 00070 assert(!exe.child_signaled()); 00071 assert(exe.child_exit_code() == 0); 00072 assert(exe.child_signal_no() == 0); 00073 } 00074 if (exe.is_child()) { 00075 char msg_from_parent[4096] = { 0 }; 00076 char *msg_to_parent = "Message from child"; 00077 char *msg_to_err = "Message from child err"; 00078 00079 if (read(exe.in_fd(), msg_from_parent, 4096) == 0) 00080 throw(ERROR(errno,"Error reading input from parent")); 00081 if (write(exe.out_fd(), msg_to_parent, strlen(msg_to_parent)) 00082 != (int)strlen(msg_to_parent)) 00083 throw(ERROR(errno,"Error writing output to parent")); 00084 if (write(exe.err_fd(), msg_to_err, strlen(msg_to_err)) 00085 != (int)strlen(msg_to_err)) 00086 throw(ERROR(errno,"Error writing error to parent")); 00087 00088 assert(static_cast<std::string>(msg_from_parent) == "Message from parent"); 00089 00090 exe.exit(); 00091 } 00092 } 00093 */ 00094 00095 /* 00096 void test3(void) 00097 { 00098 execute exe; 00099 00100 exe.fork(); 00101 if (exe.is_parent()) { 00102 char *msg_to_child = "Message from parent"; 00103 char msg_from_child[4096] = { 0 }; 00104 char msg_from_err[4096] = { 0 }; 00105 char extra_msg[4096] = { 0 }; 00106 int extra_msg_length = 0; 00107 int i; 00108 00109 assert(exe.child_running()); 00110 assert(!exe.child_exited()); 00111 assert(!exe.child_exited_normally()); 00112 assert(!exe.child_signaled()); 00113 assert(exe.child_exit_code() == 0); 00114 assert(exe.child_signal_no() == 0); 00115 00116 assert(exe.in_ready()); 00117 assert(!exe.out_ready()); 00118 assert(!exe.err_ready()); 00119 00120 sleep(1); 00121 00122 assert(exe.in_ready()); 00123 assert(!exe.out_ready()); 00124 assert(!exe.err_ready()); 00125 00126 if (write(exe.in_fd(), msg_to_child, strlen(msg_to_child)) 00127 != (int)strlen(msg_to_child)) 00128 throw(ERROR(errno,"Error writing to child's input pipe")); 00129 00130 sleep(1); 00131 00132 assert(exe.in_ready()); 00133 assert(exe.out_ready()); 00134 assert(exe.err_ready()); 00135 00136 if (read(exe.out_fd(), msg_from_child, 4096) == 0) 00137 throw(ERROR(errno,"Error reading from child's output pipe")); 00138 00139 sleep(1); 00140 00141 assert(exe.in_ready()); 00142 assert(exe.out_ready()); 00143 assert(exe.err_ready()); 00144 00145 if (read(exe.err_fd(), msg_from_err, 4096) == 0) 00146 throw(ERROR(errno,"Error reading from child's error pipe")); 00147 00148 sleep(1); 00149 00150 assert(exe.in_ready()); 00151 assert(exe.out_ready()); 00152 assert(exe.err_ready()); 00153 00154 if (exe.out_ready()) { 00155 for (i = 0; i < 4096; extra_msg[i++] = 0); 00156 extra_msg_length = read(exe.out_fd(), extra_msg, 4096); 00157 } 00158 assert(extra_msg_length == 0); 00159 if (exe.err_ready()) { 00160 for (i = 0; i < 4096; extra_msg[i++] = 0); 00161 extra_msg_length = read(exe.err_fd(), extra_msg, 4096); 00162 } 00163 assert(extra_msg_length == 0); 00164 00165 exe.wait(); 00166 00167 assert(static_cast<std::string>(msg_from_child) == "Message from child"); 00168 assert(static_cast<std::string>(msg_from_err) == "Message from child err"); 00169 assert(!exe.child_running()); 00170 assert(exe.child_exited()); 00171 assert(exe.child_exited_normally()); 00172 assert(!exe.child_signaled()); 00173 assert(exe.child_exit_code() == 0); 00174 assert(exe.child_signal_no() == 0); 00175 } 00176 if (exe.is_child()) { 00177 char msg_from_parent[4096] = { 0 }; 00178 char *msg_to_parent = "Message from child"; 00179 char *msg_to_err = "Message from child err"; 00180 00181 if (read(exe.in_fd(), msg_from_parent, 4096) == 0) 00182 throw(ERROR(errno,"Error reading input from parent")); 00183 if (write(exe.out_fd(), msg_to_parent, strlen(msg_to_parent)) 00184 != (int)strlen(msg_to_parent)) 00185 throw(ERROR(errno,"Error writing output to parent")); 00186 if (write(exe.err_fd(), msg_to_err, strlen(msg_to_err)) 00187 != (int)strlen(msg_to_err)) 00188 throw(ERROR(errno,"Error writing error to parent")); 00189 00190 assert(static_cast<std::string>(msg_from_parent) == "Message from parent"); 00191 00192 exe.exit(); 00193 } 00194 } 00195 */ 00196 00197 /* 00198 void test4(void) 00199 { 00200 execute exe; 00201 00202 exe.fork(); 00203 if (exe.is_parent()) { 00204 assert(exe.child_running()); 00205 assert(!exe.child_exited()); 00206 assert(!exe.child_exited_normally()); 00207 assert(!exe.child_signaled()); 00208 assert(exe.child_exit_code() == 0); 00209 assert(exe.child_signal_no() == 0); 00210 00211 exe.wait(); 00212 00213 assert(!exe.child_running()); 00214 assert(exe.child_exited()); 00215 assert(exe.child_exited_normally()); 00216 assert(!exe.child_signaled()); 00217 assert(exe.child_exit_code() == 5); 00218 assert(exe.child_signal_no() == 0); 00219 } 00220 else { 00221 sleep(1); 00222 exe.exit(5); 00223 } 00224 } 00225 */ 00226 00227 /* 00228 void test5(void) 00229 { 00230 execute exe; 00231 00232 exe.fork(); 00233 if (exe.is_parent()) { 00234 assert(exe.child_running()); 00235 assert(!exe.child_exited()); 00236 assert(!exe.child_exited_normally()); 00237 assert(!exe.child_signaled()); 00238 assert(exe.child_exit_code() == 0); 00239 assert(exe.child_signal_no() == 0); 00240 00241 exe.signal_child(SIGINT); 00242 exe.wait(); 00243 00244 assert(!exe.child_running()); 00245 assert(exe.child_exited()); 00246 assert(!exe.child_exited_normally()); 00247 assert(exe.child_signaled()); 00248 assert(exe.child_exit_code() == 0); 00249 assert(exe.child_signal_no() == SIGINT); 00250 } 00251 else { 00252 sleep(5); 00253 exe.exit(5); 00254 } 00255 } 00256 */ 00257 00258 void test6(void) 00259 { 00260 execute exe; 00261 std::string command = "/bin/ls -1 ./test-exec.cc"; 00262 char buffer[4096] = { 0 }; 00263 int num_bytes; 00264 00265 exe.exec(command); 00266 00267 assert(exe.child_running()); 00268 assert(!exe.child_exited()); 00269 assert(!exe.child_exited_normally()); 00270 assert(!exe.child_signaled()); 00271 assert(exe.child_exit_code() == 0); 00272 assert(exe.child_signal_no() == 0); 00273 assert(exe.in_ready()); 00274 assert(!exe.out_ready()); 00275 assert(!exe.err_ready()); 00276 00277 for (num_bytes = 0; num_bytes < 4096; buffer[num_bytes++] = 0); 00278 num_bytes = read(exe.out_fd(), buffer, 4096); 00279 assert(num_bytes = 15); 00280 assert(static_cast<std::string>(buffer) == static_cast<std::string>("./test-exec.cc\n")); 00281 00282 for (num_bytes = 0; num_bytes < 4096; buffer[num_bytes++] = 0); 00283 num_bytes = read(exe.err_fd(), buffer, 4096); 00284 assert(num_bytes == 0); 00285 assert(static_cast<std::string>(buffer).size() == 0); 00286 00287 exe.wait(); 00288 00289 assert(!exe.child_running()); 00290 assert(exe.child_exited()); 00291 assert(exe.child_exited_normally()); 00292 assert(!exe.child_signaled()); 00293 assert(exe.child_exit_code() == 0); 00294 assert(exe.child_signal_no() == 0); 00295 assert(exe.in_ready()); 00296 assert(exe.out_ready()); 00297 assert(exe.err_ready()); 00298 } 00299 00300 void test6_1(void) 00301 { 00302 execute exe; 00303 std::string command; 00304 std::vector<std::string> argv; 00305 char buffer[4096] = { 0 }; 00306 int num_bytes; 00307 00308 command = "/bin/ls"; 00309 argv.push_back(std::string("-1")); 00310 argv.push_back(std::string("./test-exec.cc")); 00311 exe.exec(command, argv); 00312 00313 assert(exe.child_running()); 00314 assert(!exe.child_exited()); 00315 assert(!exe.child_exited_normally()); 00316 assert(!exe.child_signaled()); 00317 assert(exe.child_exit_code() == 0); 00318 assert(exe.child_signal_no() == 0); 00319 assert(exe.in_ready()); 00320 assert(!exe.out_ready()); 00321 assert(!exe.err_ready()); 00322 00323 for (num_bytes = 0; num_bytes < 4096; buffer[num_bytes++] = 0); 00324 num_bytes = read(exe.out_fd(), buffer, 4096); 00325 assert(num_bytes = 15); 00326 assert(static_cast<std::string>(buffer) == static_cast<std::string>("./test-exec.cc\n")); 00327 00328 for (num_bytes = 0; num_bytes < 4096; buffer[num_bytes++] = 0); 00329 num_bytes = read(exe.err_fd(), buffer, 4096); 00330 assert(num_bytes == 0); 00331 assert(static_cast<std::string>(buffer).size() == 0); 00332 00333 exe.wait(); 00334 00335 assert(!exe.child_running()); 00336 assert(exe.child_exited()); 00337 assert(exe.child_exited_normally()); 00338 assert(!exe.child_signaled()); 00339 assert(exe.child_exit_code() == 0); 00340 assert(exe.child_signal_no() == 0); 00341 assert(exe.in_ready()); 00342 assert(exe.out_ready()); 00343 assert(exe.err_ready()); 00344 } 00345 00346 /* 00347 void test7(void) 00348 { 00349 execute exe; 00350 ofdstream fdout; 00351 00352 exe.fork(); 00353 if (exe.is_parent()) { 00354 char *msg_to_child = "Message from parent"; 00355 char msg_from_child[4096] = { 0 }; 00356 char msg_from_err[4096] = { 0 }; 00357 00358 assert(exe.child_running()); 00359 assert(!exe.child_exited()); 00360 assert(!exe.child_exited_normally()); 00361 assert(!exe.child_signaled()); 00362 assert(exe.child_exit_code() == 0); 00363 assert(exe.child_signal_no() == 0); 00364 assert(fdout.good()); 00365 00366 fdout.attach(exe.in_fd()); 00367 fdout << msg_to_child; 00368 fdout.flush(); 00369 00370 assert(fdout.good()); 00371 00372 if (read(exe.out_fd(), msg_from_child, 4096) == 0) 00373 throw(ERROR(errno,"Error reading from child's output pipe")); 00374 if (read(exe.err_fd(), msg_from_err, 4096) == 0) 00375 throw(ERROR(errno,"Error reading from child's error pipe")); 00376 00377 exe.wait(); 00378 00379 assert(fdout.good()); 00380 00381 assert(static_cast<std::string>(msg_from_child) == "Message from child"); 00382 assert(static_cast<std::string>(msg_from_err) == "Message from child err"); 00383 assert(!exe.child_running()); 00384 assert(exe.child_exited()); 00385 assert(exe.child_exited_normally()); 00386 assert(!exe.child_signaled()); 00387 assert(exe.child_exit_code() == 0); 00388 assert(exe.child_signal_no() == 0); 00389 } 00390 else { 00391 char msg_from_parent[4096] = { 0 }; 00392 char *msg_to_parent = "Message from child"; 00393 char *msg_to_err = "Message from child err"; 00394 00395 if (read(exe.in_fd(), msg_from_parent, 4096) == 0) 00396 throw(ERROR(errno,"Error reading input from parent")); 00397 if (write(exe.out_fd(), msg_to_parent, strlen(msg_to_parent)) 00398 != (int)strlen(msg_to_parent)) 00399 throw(ERROR(errno,"Error writing output to parent")); 00400 if (write(exe.err_fd(), msg_to_err, strlen(msg_to_err)) 00401 != (int)strlen(msg_to_err)) 00402 throw(ERROR(errno,"Error writing error to parent")); 00403 00404 assert(static_cast<std::string>(msg_from_parent) == "Message from parent"); 00405 00406 exe.exit(); 00407 } 00408 } 00409 */ 00410 00411 /* 00412 void test8(void) 00413 { 00414 execute exe; 00415 ofdstream fdout; 00416 ifdstream fdin; 00417 00418 exe.fork(); 00419 if (exe.is_parent()) { 00420 char *msg_to_child = "Message from parent"; 00421 char msg_from_child[4096] = { 0 }; 00422 char msg_from_err[4096] = { 0 }; 00423 00424 assert(exe.child_running()); 00425 assert(!exe.child_exited()); 00426 assert(!exe.child_exited_normally()); 00427 assert(!exe.child_signaled()); 00428 assert(exe.child_exit_code() == 0); 00429 assert(exe.child_signal_no() == 0); 00430 00431 fdout.attach(exe.in_fd()); 00432 fdout << msg_to_child; 00433 fdout.flush(); 00434 00435 fdin.attach(exe.out_fd()); 00436 fdin.get(msg_from_child,4096); 00437 00438 if (read(exe.err_fd(), msg_from_err, 4096) == 0) 00439 throw(ERROR(errno,"Error reading from child's error pipe")); 00440 00441 exe.wait(); 00442 00443 assert(static_cast<std::string>(msg_from_child) == "Message from child"); 00444 assert(static_cast<std::string>(msg_from_err) == "Message from child err"); 00445 assert(!exe.child_running()); 00446 assert(exe.child_exited()); 00447 assert(exe.child_exited_normally()); 00448 assert(!exe.child_signaled()); 00449 assert(exe.child_exit_code() == 0); 00450 assert(exe.child_signal_no() == 0); 00451 } 00452 else { 00453 char msg_from_parent[4096] = { 0 }; 00454 char *msg_to_parent = "Message from child"; 00455 char *msg_to_err = "Message from child err"; 00456 00457 if (read(exe.in_fd(), msg_from_parent, 4096) == 0) 00458 throw(ERROR(errno,"Error reading input from parent")); 00459 if (write(exe.out_fd(), msg_to_parent, strlen(msg_to_parent)) 00460 != (int)strlen(msg_to_parent)) 00461 throw(ERROR(errno,"Error writing output to parent")); 00462 if (write(exe.err_fd(), msg_to_err, strlen(msg_to_err)) 00463 != (int)strlen(msg_to_err)) 00464 throw(ERROR(errno,"Error writing error to parent")); 00465 00466 assert(static_cast<std::string>(msg_from_parent) == "Message from parent"); 00467 00468 exe.exit(); 00469 } 00470 } 00471 */ 00472 00473 /* 00474 void test9(void) 00475 { 00476 execute exe; 00477 ofdstream fdout; 00478 ifdstream fdin; 00479 00480 exe.fork(); 00481 if (exe.is_parent()) { 00482 char *msg_to_child = "Message from parent"; 00483 char msg_from_child[4096] = { 0 }; 00484 char msg_from_err[4096] = { 0 }; 00485 00486 assert(exe.child_running()); 00487 assert(!exe.child_exited()); 00488 assert(!exe.child_exited_normally()); 00489 assert(!exe.child_signaled()); 00490 assert(exe.child_exit_code() == 0); 00491 assert(exe.child_signal_no() == 0); 00492 00493 fdout.attach(exe.in_fd()); 00494 // fdout << msg_to_child; 00495 // fdout.flush(); 00496 if (write(exe.in_fd(), msg_to_child, strlen(msg_to_child)) 00497 != (int)strlen(msg_to_child)) 00498 throw(ERROR(errno,"Error writing to child's input pipe")); 00499 00500 fdin.attach(exe.out_fd()); 00501 // fdin.get(msg_from_child,4096); 00502 if (read(exe.out_fd(), msg_from_child, 4096) == 0) 00503 throw(ERROR(errno,"Error reading from child's output pipe")); 00504 00505 if (read(exe.err_fd(), msg_from_err, 4096) == 0) 00506 throw(ERROR(errno,"Error reading from child's error pipe")); 00507 00508 exe.wait(); 00509 00510 assert(static_cast<std::string>(msg_from_child) == "Message from child"); 00511 assert(static_cast<std::string>(msg_from_err) == "Message from child err"); 00512 assert(!exe.child_running()); 00513 assert(exe.child_exited()); 00514 assert(exe.child_exited_normally()); 00515 assert(!exe.child_signaled()); 00516 assert(exe.child_exit_code() == 0); 00517 assert(exe.child_signal_no() == 0); 00518 } 00519 else { 00520 char msg_from_parent[4096] = { 0 }; 00521 char *msg_to_parent = "Message from child"; 00522 char *msg_to_err = "Message from child err"; 00523 00524 if (read(exe.in_fd(), msg_from_parent, 4096) == 0) 00525 throw(ERROR(errno,"Error reading input from parent")); 00526 if (write(exe.out_fd(), msg_to_parent, strlen(msg_to_parent)) 00527 != (int)strlen(msg_to_parent)) 00528 throw(ERROR(errno,"Error writing output to parent")); 00529 if (write(exe.err_fd(), msg_to_err, strlen(msg_to_err)) 00530 != (int)strlen(msg_to_err)) 00531 throw(ERROR(errno,"Error writing error to parent")); 00532 00533 assert(static_cast<std::string>(msg_from_parent) == "Message from parent"); 00534 00535 exe.exit(); 00536 } 00537 } 00538 */ 00539 00540 void test10(void) 00541 { 00542 execute exe; 00543 00544 exe.fork(); 00545 if (exe.is_parent()) { 00546 char *msg_to_child = "Message from parent"; 00547 char msg_from_child[4096] = { 0 }; 00548 char msg_from_err[4096] = { 0 }; 00549 00550 assert(exe.child_running()); 00551 assert(!exe.child_exited()); 00552 assert(!exe.child_exited_normally()); 00553 assert(!exe.child_signaled()); 00554 assert(exe.child_exit_code() == 0); 00555 assert(exe.child_signal_no() == 0); 00556 00557 assert(exe.in_ready()); 00558 assert(!exe.out_ready()); 00559 assert(!exe.err_ready()); 00560 assert(!exe.in_eof()); 00561 assert(!exe.out_eof()); 00562 assert(!exe.err_eof()); 00563 00564 if (exe.in_write(msg_to_child, strlen(msg_to_child)) 00565 != (int)strlen(msg_to_child)) 00566 throw(ERROR(errno,"Error writing to child's input pipe")); 00567 00568 // Wait until input is ready from child 00569 while (!exe.out_ready() && !exe.err_ready()); 00570 00571 assert(exe.in_ready()); 00572 assert(exe.out_ready()); 00573 assert(exe.err_ready()); 00574 assert(!exe.in_eof()); 00575 assert(!exe.out_eof()); 00576 assert(!exe.err_eof()); 00577 00578 if (exe.out_read(msg_from_child, 4096) == 0) 00579 throw(ERROR(errno,"Error reading from child's output pipe")); 00580 00581 assert(exe.in_ready()); 00582 00583 assert(!exe.out_ready() || !exe.child_running()); 00584 assert(exe.err_ready()); 00585 assert(!exe.in_eof()); 00586 assert(!exe.out_eof()); 00587 assert(!exe.err_eof()); 00588 00589 if (exe.err_read(msg_from_err, 4096) == 0) 00590 throw(ERROR(errno,"Error reading from child's error pipe")); 00591 00592 while (!exe.out_ready() && !exe.err_ready()); 00593 00594 assert(exe.in_ready()); 00595 assert(exe.out_ready()); 00596 assert(exe.err_ready()); 00597 assert(!exe.in_eof()); 00598 assert(!exe.out_eof()); 00599 assert(!exe.err_eof()); 00600 00601 exe.wait(); 00602 00603 assert(exe.in_ready()); 00604 assert(exe.out_ready()); 00605 assert(exe.err_ready()); 00606 assert(!exe.in_eof()); 00607 assert(!exe.out_eof()); 00608 assert(!exe.err_eof()); 00609 00610 assert(static_cast<std::string>(msg_from_child) == "Message from child"); 00611 assert(static_cast<std::string>(msg_from_err) == "Message from child err"); 00612 00613 assert(exe.out_read(msg_from_child, 4096) == 0); 00614 assert(exe.in_ready()); 00615 assert(exe.out_ready()); 00616 assert(exe.err_ready()); 00617 assert(!exe.in_eof()); 00618 assert(exe.out_eof()); 00619 assert(!exe.err_eof()); 00620 00621 assert(!exe.child_running()); 00622 assert(exe.child_exited()); 00623 assert(exe.child_exited_normally()); 00624 assert(!exe.child_signaled()); 00625 assert(exe.child_exit_code() == 0); 00626 assert(exe.child_signal_no() == 0); 00627 } 00628 if (exe.is_child()) { 00629 char msg_from_parent[4096] = { 0 }; 00630 char *msg_to_parent = "Message from child"; 00631 char *msg_to_err = "Message from child err"; 00632 00633 if (read(exe.in_fd(), msg_from_parent, 4096) == 0) 00634 throw(ERROR(errno,"Error reading input from parent")); 00635 if (write(exe.out_fd(), msg_to_parent, strlen(msg_to_parent)) 00636 != (int)strlen(msg_to_parent)) 00637 throw(ERROR(errno,"Error writing output to parent")); 00638 if (write(exe.err_fd(), msg_to_err, strlen(msg_to_err)) 00639 != (int)strlen(msg_to_err)) 00640 throw(ERROR(errno,"Error writing error to parent")); 00641 00642 assert(static_cast<std::string>(msg_from_parent) == "Message from parent"); 00643 00644 sleep(5); 00645 exe.exit(); 00646 } 00647 } 00648 00649 int main(int argc, char *argv[]) 00650 { 00651 try { 00652 /* 00653 test1(); 00654 test2(); 00655 test3(); 00656 test4(); 00657 test5(); 00658 */ 00659 test6(); 00660 test6_1(); 00661 /* 00662 test7(); 00663 test8(); 00664 test9(); 00665 */ 00666 test10(); 00667 } 00668 catch(error e) { 00669 std::cerr << e; 00670 assert(0); 00671 } 00672 catch(...) { 00673 std::cerr << err_unknown; 00674 assert(0); 00675 } 00676 return(0); 00677 } 00678