- if ((hook = context_find(hook_name)) == (char *)0)
- return (OK);
-
- switch (pid = vfork()) {
- case -1:
- status = NOTOK;
- advise(NULL, "external database may be out-of-date.");
- break;
-
- case 0:
- vec[0] = r1bindex(hook, '/');
- vec[1] = message_file_name_1;
- vec[2] = message_file_name_2;
- vec[3] = (char *)0;
- execvp(hook, vec);
- _exit(-1);
- /* NOTREACHED */
-
- default:
- status = pidwait(pid, -1);
- break;
- }
-
- if (status != OK) {
- if (did_message == 0) {
- if ((hook = context_find("msg-hook")) != (char *)0)
- advise(NULL, hook);
- else
- advise(NULL, "external hook (%s) did not work properly.", hook);
-
- did_message = 1;
+ if (!(hook = context_find(hook_name))) {
+ return (OK);
+ }
+ status = execprogl(mhbasename(hook), mhbasename(hook),
+ msg_filename1, msg_filename2,
+ (char *)NULL);
+ if (status != OK) {
+ if (did_message) {
+ return (NOTOK);
+ }
+ if ((hook = context_find("msg-hook"))) {
+ advise(NULL, hook);
+ } else {
+ advise(NULL, "external hook (%s) failed.", hook);
+ }
+ did_message = 1;
+ return (NOTOK);
+ } else {
+ return (OK);