Ignore:
Timestamp:
Sep 9, 2020, 10:01:39 PM (5 years ago)
Author:
bird
Message:

kash: Hammering on threaded mode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kash/shinstance.h

    r3435 r3438  
    6565typedef struct shchild
    6666{
    67     pid_t       pid;                    /**< The pid. */
     67    shpid       pid;                    /**< The pid. */
    6868#if K_OS == K_OS_WINDOWS
    6969    void       *hChild;                 /**< The process handle. */
     70#endif
     71#ifndef SH_FORKED_MODE
     72    KBOOL       fProcess;               /**< Set if process, clear if internal thread. */
    7073#endif
    7174} shchild;
     
    140143    struct shinstance  *prev;           /**< The previous shell instance. */
    141144    struct shinstance  *parent;         /**< The parent shell instance. */
    142     pid_t               pid;            /**< The (fake) process id of this shell instance. */
     145    shpid               pid;            /**< The (fake) process id of this shell instance. */
    143146    shtid               tid;            /**< The thread identifier of the thread for this shell. */
     147    shpid               pgid;           /**< Process group ID. */
    144148    shfdtab             fdtab;          /**< The file descriptor table. */
    145149    shsigaction_t       sigactions[NSIG]; /**< The signal actions registered with this shell instance. */
     
    148152    int                 num_children;   /**< Number of children in the array. */
    149153    shchild            *children;       /**< The child array. */
     154#ifndef SH_FORKED_MODE
     155    int (*thread)(struct shinstance *, void *); /**< The thread procedure. */
     156    void               *threadarg;      /**< The thread argument. */
     157#endif
    150158
    151159    /* alias.c */
    152160#define ATABSIZE 39
    153161    struct alias       *atab[ATABSIZE];
     162    unsigned            aliases;        /**< Number of active aliases. */
    154163
    155164    /* cd.c */
     
    178187    int                 skipcount;      /**< number of levels to skip */
    179188    int                 loopnest;       /**< current loop nesting level */
     189    int                 commandnamemalloc; /**< Set if commandname is malloc'ed (only subshells). */
    180190
    181191    /* expand.c */
     
    210220
    211221    /* jobs.h */
    212     pid_t               backgndpid/* = -1 */;   /**< pid of last background process */
     222    shpid               backgndpid/* = -1 */;   /**< pid of last background process */
    213223    int                 job_warning;    /**< user was warned about stopped jobs */
    214224
     
    217227    int                 njobs;          /**< size of array */
    218228    int                 jobs_invalid;   /**< set in child */
    219     int                 initialpgrp;    /**< pgrp of shell on invocation */
     229    shpid               initialpgrp;    /**< pgrp of shell on invocation */
    220230    int                 curjob/* = -1*/;/**< current job */
    221231    int                 ttyfd/* = -1*/;
     
    231241
    232242    /* main.h */
    233     int                 rootpid;        /**< pid of main shell. */
     243    shpid               rootpid;        /**< pid of main shell. */
    234244    int                 rootshell;      /**< true if we aren't a child of the main shell. */
    235245    struct shinstance  *psh_rootshell;  /**< The root shell pointer. (!rootshell) */
     
    272282    char               *optionarg;      /**< set by nextopt */
    273283    char               *optptr;         /**< used by nextopt */
     284    char              **orgargv;        /**< The original argument vector (for cleanup). */
     285    int                 arg0malloc;     /**< Indicates whether arg0 was allocated or is part of orgargv. */
    274286
    275287    /* parse.h */
     
    346358
    347359
    348 extern shinstance *sh_create_root_shell(shinstance *, int, char **, char **);
     360extern shinstance *sh_create_root_shell(char **, char **);
     361extern shinstance *sh_create_child_shell(shinstance *);
    349362
    350363/* environment & pwd.h */
     
    395408SH_NORETURN_1 void sh_abort(shinstance *) SH_NORETURN_2;
    396409void sh_raise_sigint(shinstance *);
    397 int sh_kill(shinstance *, pid_t, int);
    398 int sh_killpg(shinstance *, pid_t, int);
     410int sh_kill(shinstance *, shpid, int);
     411int sh_killpg(shinstance *, shpid, int);
    399412
    400413/* times */
     
    416429
    417430/* wait / process */
    418 int sh_add_child(shinstance *psh, pid_t pid, void *hChild);
     431int sh_add_child(shinstance *psh, shpid pid, void *hChild, KBOOL fProcess);
    419432#ifdef _MSC_VER
    420433#   include <process.h>
     
    442455#   endif
    443456#endif
    444 pid_t sh_fork(shinstance *);
    445 pid_t sh_waitpid(shinstance *, pid_t, int *, int);
     457#ifdef SH_FORKED_MODE
     458shpid sh_fork(shinstance *);
     459#else
     460shpid sh_thread_start(shinstance *pshparent, shinstance *pshchild, int (*thread)(shinstance *, void *), void *arg);
     461#endif
     462shpid sh_waitpid(shinstance *, shpid, int *, int);
    446463SH_NORETURN_1 void sh__exit(shinstance *, int) SH_NORETURN_2;
    447464int sh_execve(shinstance *, const char *, const char * const*, const char * const *);
     
    450467gid_t sh_getgid(shinstance *);
    451468gid_t sh_getegid(shinstance *);
    452 pid_t sh_getpid(shinstance *);
    453 pid_t sh_getpgrp(shinstance *);
    454 pid_t sh_getpgid(shinstance *, pid_t);
    455 int sh_setpgid(shinstance *, pid_t, pid_t);
     469shpid sh_getpid(shinstance *);
     470shpid sh_getpgrp(shinstance *);
     471shpid sh_getpgid(shinstance *, shpid);
     472int sh_setpgid(shinstance *, shpid, shpid);
    456473
    457474/* tc* */
    458 pid_t sh_tcgetpgrp(shinstance *, int);
    459 int sh_tcsetpgrp(shinstance *, int, pid_t);
     475shpid sh_tcgetpgrp(shinstance *, int);
     476int sh_tcsetpgrp(shinstance *, int, shpid);
    460477
    461478/* sys/resource.h */
Note: See TracChangeset for help on using the changeset viewer.