Changeset 700c712


Ignore:
Timestamp:
Sep 25, 2002, 3:59:56 PM (21 years ago)
Author:
James M. Kretchmar <kretch@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
55faab7
Parents:
601a9e0
Message:
Started adding code for newmsgproc.  It doesn't fully work yet!
  Don't use it!
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r601a9e0 r700c712  
    11$Id$
     21.2.6
     3        Started adding code for newmsgproc.  It doesn't fully work yet!
     4          Don't use it.
     5       
    261.2.5
    37        Patch to fix memory bug in replying to CC messages
  • global.c

    r61e79a9 r700c712  
    6262  g->starttime=time(NULL); /* assumes we call init only a start time */
    6363  strcpy(g->buffercommand, "");
    64 
     64  g->newmsgproc_pid=0;
    6565 
    6666  owl_global_set_config_format(g, 0);
     
    598598  return(g->searchstring);
    599599}
     600
     601void owl_global_set_newmsgproc_pid(owl_global *g, int i) {
     602  g->newmsgproc_pid=i;
     603}
     604
     605int owl_global_get_newmsgproc_pid(owl_global *g) {
     606  return(g->newmsgproc_pid);
     607}
     608
  • owl.c

    r601a9e0 r700c712  
    2121#include <time.h>
    2222#include <sys/param.h>
     23#include <sys/types.h>
     24#include <sys/wait.h>
     25#include <errno.h>
    2326#include "owl.h"
    2427
     
    325328    if (newzephyrs && followlast) {
    326329      owl_function_lastmsg_noredisplay();
     330    }
     331
     332    /* check if newmsgproc is active, if not but the option is on,
     333       make it active */
     334    if (newzephyrs) {
     335      if (owl_global_get_newmsgproc(&g) && strcmp(owl_global_get_newmsgproc(&g), "")) {
     336        /* if there's a process out there, we need to check on it */
     337        if (owl_global_get_newmsgproc_pid(&g)) {
     338          owl_function_debugmsg("Checking on newmsgproc pid==%i", owl_global_get_newmsgproc_pid(&g));
     339          owl_function_debugmsg("Waitpid return is %i", waitpid(owl_global_get_newmsgproc_pid(&g), NULL, WNOHANG));
     340          waitpid(owl_global_get_newmsgproc_pid(&g), NULL, WNOHANG);
     341          if (waitpid(owl_global_get_newmsgproc_pid(&g), NULL, WNOHANG)==-1) {
     342            /* it exited */
     343            owl_global_set_newmsgproc_pid(&g, 0);
     344            owl_function_debugmsg("newmsgproc exited");
     345          } else {
     346            owl_function_debugmsg("newmsgproc did not exit");
     347          }
     348        }
     349       
     350        /* if it exited, fork & exec a new one */
     351        if (owl_global_get_newmsgproc_pid(&g)==0) {
     352          int i, argc;
     353          i=fork();
     354          if (i) {
     355            /* parent set the child's pid */
     356            owl_global_set_newmsgproc_pid(&g, i);
     357            waitpid(i, NULL, WNOHANG);
     358            owl_function_debugmsg("I'm the parent and I started a new newmsgproc with pid %i", i);
     359          } else {
     360            /* child exec's the program */
     361            char **parsed;
     362           
     363            parsed=owl_parseline(owl_global_get_newmsgproc(&g), &argc);
     364            parsed=realloc(parsed, strlen(owl_global_get_newmsgproc(&g)+300));
     365            parsed[argc]='\0';
     366
     367            owl_function_debugmsg("About to exec: -%s- with %i arguments", parsed[0], argc);
     368
     369            execvp(*parsed, parsed);
     370           
     371
     372            /* was there an error exec'ing? */
     373            owl_function_debugmsg("Error execing: %s", strerror(errno));
     374            _exit(127);
     375          }
     376        }
     377      }
    327378    }
    328379   
  • owl.h

    r601a9e0 r700c712  
    386386  int colorpairs;
    387387  int searchactive;
     388  int newmsgproc_pid;
    388389  char *searchstring;
    389390  owl_filterelement fe_true;
  • variable.c

    rf9c43ae r700c712  
    147147               "This program should produce a zsig on stdout when run.\n"
    148148               "Note that it is important that this program not block.\n" ),
     149
     150  OWLVAR_PATH( "newmsgproc" /* %OwlVarStub:newmsgproc */, NULL,
     151               "name of a program to run when new messages are present",
     152               "The named program will be run when owl recevies new.\n"
     153               "messages.  It will not be run again until the first\n"
     154               "instance exits"),
    149155
    150156  OWLVAR_STRING( "zsig" /* %OwlVarStub */, "",
Note: See TracChangeset for help on using the changeset viewer.