X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/e99573743b82d936081e56f59e5881d53b4fed91..c0a87b2e2dfa156bfb4e6c0e5d43f7a582f779fc:/sbr/folder_delmsgs.c diff --git a/sbr/folder_delmsgs.c b/sbr/folder_delmsgs.c index c1416a6f..ee4bd9e9 100644 --- a/sbr/folder_delmsgs.c +++ b/sbr/folder_delmsgs.c @@ -24,7 +24,7 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) { pid_t pid; int msgnum, vecp, retval = 0; - char buf[100], *dp, **vec; + char buf[100], *dp, **vec, *prog; char msgpath[BUFSIZ]; /* @@ -40,10 +40,26 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; - vec = (char **) calloc ((size_t) (mp->numsel + 2), sizeof(*vec)); + /* + * Write out the sequence and context files; this will release + * any locks before the rmmproc is called. + */ + + seq_save (mp); + context_save (); + + vec = argsplit(rmmproc, &prog, &vecp); + + /* + * argsplit allocates a MAXARGS vector by default, If we need + * something bigger, allocate it ourselves + */ + + if (mp->numsel + vecp + 1 > MAXARGS) + vec = (char **) realloc (vec, (size_t) ((mp->numsel + vecp + 1) * + sizeof(*vec))); if (vec == NULL) adios (NULL, "unable to allocate exec vector"); - vecp = 1; for (msgnum = mp->lowsel; msgnum <= mp->hghsel; msgnum++) { if (is_selected (mp, msgnum) && !(vec[vecp++] = strdup (m_name (msgnum)))) @@ -52,20 +68,20 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) vec[vecp] = NULL; fflush (stdout); - vec[0] = r1bindex (rmmproc, '/'); - switch (pid = vfork()) { + switch (pid = fork()) { case -1: advise ("fork", "unable to"); return -1; case 0: - execvp (rmmproc, vec); + execvp (prog, vec); fprintf (stderr, "unable to exec "); perror (rmmproc); _exit (-1); default: + arglist_free(prog, vec); return (pidwait (pid, -1)); } } @@ -124,5 +140,12 @@ folder_delmsgs (struct msgs *mp, int unlink_msgs, int nohook) /* Mark that the sequence information has changed */ mp->msgflags |= SEQMOD; + /* + * Write out sequence and context files + */ + + seq_save (mp); + context_save (); + return retval; }