| 1 | /* $Id: shinstance.h 1785 2008-09-14 17:31:16Z bird $ */
|
|---|
| 2 | /** @file
|
|---|
| 3 | *
|
|---|
| 4 | * The shell instance and it's methods.
|
|---|
| 5 | *
|
|---|
| 6 | * Copyright (c) 2007 knut st. osmundsen <bird-src-spam@anduin.net>
|
|---|
| 7 | *
|
|---|
| 8 | *
|
|---|
| 9 | * This file is part of kBuild.
|
|---|
| 10 | *
|
|---|
| 11 | * kBuild is free software; you can redistribute it and/or modify
|
|---|
| 12 | * it under the terms of the GNU General Public License as published by
|
|---|
| 13 | * the Free Software Foundation; either version 2 of the License, or
|
|---|
| 14 | * (at your option) any later version.
|
|---|
| 15 | *
|
|---|
| 16 | * kBuild is distributed in the hope that it will be useful,
|
|---|
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 19 | * GNU General Public License for more details.
|
|---|
| 20 | *
|
|---|
| 21 | * You should have received a copy of the GNU General Public License
|
|---|
| 22 | * along with kBuild; if not, write to the Free Software
|
|---|
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 24 | *
|
|---|
| 25 | */
|
|---|
| 26 |
|
|---|
| 27 | #ifndef ___shinstance_h
|
|---|
| 28 | #define ___shinstance_h
|
|---|
| 29 |
|
|---|
| 30 | #include <stdio.h> /* BUFSIZ */
|
|---|
| 31 | #include <signal.h> /* NSIG */
|
|---|
| 32 | #ifndef _MSC_VER
|
|---|
| 33 | # include <termios.h>
|
|---|
| 34 | # include <sys/ioctl.h>
|
|---|
| 35 | # include <sys/resource.h>
|
|---|
| 36 | #endif
|
|---|
| 37 | #include <errno.h>
|
|---|
| 38 | #ifdef _MSC_VER
|
|---|
| 39 | # define EWOULDBLOCK 512
|
|---|
| 40 | #endif
|
|---|
| 41 |
|
|---|
| 42 | #include "shtypes.h"
|
|---|
| 43 | #include "shthread.h"
|
|---|
| 44 | #include "shfile.h"
|
|---|
| 45 | #include "shell.h"
|
|---|
| 46 | #include "output.h"
|
|---|
| 47 | #include "options.h"
|
|---|
| 48 |
|
|---|
| 49 | #include "expand.h"
|
|---|
| 50 | #include "exec.h"
|
|---|
| 51 | #include "var.h"
|
|---|
| 52 | #include "show.h"
|
|---|
| 53 |
|
|---|
| 54 | #ifdef _MSC_VER
|
|---|
| 55 | # define strcasecmp stricmp
|
|---|
| 56 | # define strncasecmp strnicmp
|
|---|
| 57 | #endif
|
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 | /* memalloc.c */
|
|---|
| 61 | #define MINSIZE 504 /* minimum size of a block */
|
|---|
| 62 | struct stack_block {
|
|---|
| 63 | struct stack_block *prev;
|
|---|
| 64 | char space[MINSIZE];
|
|---|
| 65 | };
|
|---|
| 66 |
|
|---|
| 67 | /* input.c */
|
|---|
| 68 | struct strpush {
|
|---|
| 69 | struct strpush *prev; /* preceding string on stack */
|
|---|
| 70 | char *prevstring;
|
|---|
| 71 | int prevnleft;
|
|---|
| 72 | int prevlleft;
|
|---|
| 73 | struct alias *ap; /* if push was associated with an alias */
|
|---|
| 74 | };
|
|---|
| 75 |
|
|---|
| 76 | /*
|
|---|
| 77 | * The parsefile structure pointed to by the global variable parsefile
|
|---|
| 78 | * contains information about the current file being read.
|
|---|
| 79 | */
|
|---|
| 80 | struct parsefile {
|
|---|
| 81 | struct parsefile *prev; /* preceding file on stack */
|
|---|
| 82 | int linno; /* current line */
|
|---|
| 83 | int fd; /* file descriptor (or -1 if string) */
|
|---|
| 84 | int nleft; /* number of chars left in this line */
|
|---|
| 85 | int lleft; /* number of chars left in this buffer */
|
|---|
| 86 | char *nextc; /* next char in buffer */
|
|---|
| 87 | char *buf; /* input buffer */
|
|---|
| 88 | struct strpush *strpush; /* for pushing strings at this level */
|
|---|
| 89 | struct strpush basestrpush; /* so pushing one is fast */
|
|---|
| 90 | };
|
|---|
| 91 |
|
|---|
| 92 | /* exec.c */
|
|---|
| 93 | #define CMDTABLESIZE 31 /* should be prime */
|
|---|
| 94 | #define ARB 1 /* actual size determined at run time */
|
|---|
| 95 |
|
|---|
| 96 | struct tblentry {
|
|---|
| 97 | struct tblentry *next; /* next entry in hash chain */
|
|---|
| 98 | union param param; /* definition of builtin function */
|
|---|
| 99 | short cmdtype; /* index identifying command */
|
|---|
| 100 | char rehash; /* if set, cd done since entry created */
|
|---|
| 101 | char cmdname[ARB]; /* name of command */
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | /* expand.c */
|
|---|
| 105 | /*
|
|---|
| 106 | * Structure specifying which parts of the string should be searched
|
|---|
| 107 | * for IFS characters.
|
|---|
| 108 | */
|
|---|
| 109 | struct ifsregion {
|
|---|
| 110 | struct ifsregion *next; /* next region in list */
|
|---|
| 111 | int begoff; /* offset of start of region */
|
|---|
| 112 | int endoff; /* offset of end of region */
|
|---|
| 113 | int inquotes; /* search for nul bytes only */
|
|---|
| 114 | };
|
|---|
| 115 |
|
|---|
| 116 |
|
|---|
| 117 | /**
|
|---|
| 118 | * A shell instance.
|
|---|
| 119 | *
|
|---|
| 120 | * This is the core structure of the shell, it contains all
|
|---|
| 121 | * the data associated with a shell process except that it's
|
|---|
| 122 | * running in a thread and not a separate process.
|
|---|
| 123 | */
|
|---|
| 124 | struct shinstance
|
|---|
| 125 | {
|
|---|
| 126 | struct shinstance *next; /**< The next shell instance. */
|
|---|
| 127 | struct shinstance *prev; /**< The previous shell instance. */
|
|---|
| 128 | struct shinstance *parent; /**< The parent shell instance. */
|
|---|
| 129 | pid_t pid; /**< The (fake) process id of this shell instance. */
|
|---|
| 130 | shtid tid; /**< The thread identifier of the thread for this shell. */
|
|---|
| 131 | shfdtab fdtab; /**< The file descriptor table. */
|
|---|
| 132 | shsigaction_t sigactions[NSIG]; /**< The signal actions registered with this shell instance. */
|
|---|
| 133 |
|
|---|
| 134 | /* alias.c */
|
|---|
| 135 | #define ATABSIZE 39
|
|---|
| 136 | struct alias *atab[ATABSIZE];
|
|---|
| 137 |
|
|---|
| 138 | /* cd.c */
|
|---|
| 139 | char *curdir; /**< current working directory */
|
|---|
| 140 | char *prevdir; /**< previous working directory */
|
|---|
| 141 | char *cdcomppath;
|
|---|
| 142 | int getpwd_first; /**< static in getpwd. (initialized to 1!) */
|
|---|
| 143 |
|
|---|
| 144 | /* error.h */
|
|---|
| 145 | struct jmploc *handler;
|
|---|
| 146 | int exception;
|
|---|
| 147 | int exerrno/* = 0 */; /**< Last exec error */
|
|---|
| 148 | int volatile suppressint;
|
|---|
| 149 | int volatile intpending;
|
|---|
| 150 |
|
|---|
| 151 | /* error.c */
|
|---|
| 152 | char errmsg_buf[16]; /**< static in errmsg. (bss) */
|
|---|
| 153 |
|
|---|
| 154 | /* eval.h */
|
|---|
| 155 | char *commandname; /**< currently executing command */
|
|---|
| 156 | int exitstatus; /**< exit status of last command */
|
|---|
| 157 | int back_exitstatus;/**< exit status of backquoted command */
|
|---|
| 158 | struct strlist *cmdenviron; /**< environment for builtin command */
|
|---|
| 159 | int funcnest; /**< depth of function calls */
|
|---|
| 160 | int evalskip; /**< set if we are skipping commands */
|
|---|
| 161 | int skipcount; /**< number of levels to skip */
|
|---|
| 162 | int loopnest; /**< current loop nesting level */
|
|---|
| 163 |
|
|---|
| 164 | /* eval.c */
|
|---|
| 165 | int vforked;
|
|---|
| 166 |
|
|---|
| 167 | /* expand.c */
|
|---|
| 168 | char *expdest; /**< output of current string */
|
|---|
| 169 | struct nodelist *argbackq; /**< list of back quote expressions */
|
|---|
| 170 | struct ifsregion ifsfirst; /**< first struct in list of ifs regions */
|
|---|
| 171 | struct ifsregion *ifslastp; /**< last struct in list */
|
|---|
| 172 | struct arglist exparg; /**< holds expanded arg list */
|
|---|
| 173 | char *expdir; /**< Used by expandmeta. */
|
|---|
| 174 |
|
|---|
| 175 | /* exec.h */
|
|---|
| 176 | const char *pathopt; /**< set by padvance */
|
|---|
| 177 |
|
|---|
| 178 | /* exec.c */
|
|---|
| 179 | struct tblentry *cmdtable[CMDTABLESIZE];
|
|---|
| 180 | int builtinloc/* = -1*/; /**< index in path of %builtin, or -1 */
|
|---|
| 181 |
|
|---|
| 182 | /* input.h */
|
|---|
| 183 | int plinno/* = 1 */;/**< input line number */
|
|---|
| 184 | int parsenleft; /**< number of characters left in input buffer */
|
|---|
| 185 | char *parsenextc; /**< next character in input buffer */
|
|---|
| 186 | int init_editline/* = 0 */; /**< 0 == not setup, 1 == OK, -1 == failed */
|
|---|
| 187 |
|
|---|
| 188 | /* input.c */
|
|---|
| 189 | int parselleft; /**< copy of parsefile->lleft */
|
|---|
| 190 | struct parsefile basepf; /**< top level input file */
|
|---|
| 191 | char basebuf[BUFSIZ];/**< buffer for top level input file */
|
|---|
| 192 | struct parsefile *parsefile/* = &basepf*/; /**< current input file */
|
|---|
| 193 | #ifndef SMALL
|
|---|
| 194 | EditLine *el; /**< cookie for editline package */
|
|---|
| 195 | #endif
|
|---|
| 196 |
|
|---|
| 197 | /* jobs.h */
|
|---|
| 198 | pid_t backgndpid/* = -1 */; /**< pid of last background process */
|
|---|
| 199 | int job_warning; /**< user was warned about stopped jobs */
|
|---|
| 200 |
|
|---|
| 201 | /* jobs.c */
|
|---|
| 202 | struct job *jobtab; /**< array of jobs */
|
|---|
| 203 | int njobs; /**< size of array */
|
|---|
| 204 | int jobs_invalid; /**< set in child */
|
|---|
| 205 | int initialpgrp; /**< pgrp of shell on invocation */
|
|---|
| 206 | int curjob/* = -1*/;/**< current job */
|
|---|
| 207 | int ttyfd/* = -1*/;
|
|---|
| 208 | int jobctl; /**< job control enabled / disabled */
|
|---|
| 209 | char *cmdnextc;
|
|---|
| 210 | int cmdnleft;
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 | /* mail.c */
|
|---|
| 214 | #define MAXMBOXES 10
|
|---|
| 215 | int nmboxes; /**< number of mailboxes */
|
|---|
| 216 | time_t mailtime[MAXMBOXES]; /**< times of mailboxes */
|
|---|
| 217 |
|
|---|
| 218 | /* main.h */
|
|---|
| 219 | int rootpid; /**< pid of main shell. */
|
|---|
| 220 | int rootshell; /**< true if we aren't a child of the main shell. */
|
|---|
| 221 | struct shinstance *psh_rootshell; /**< The root shell pointer. (!rootshell) */
|
|---|
| 222 |
|
|---|
| 223 | /* memalloc.h */
|
|---|
| 224 | char *stacknxt/* = stackbase.space*/;
|
|---|
| 225 | int stacknleft/* = MINSIZE*/;
|
|---|
| 226 | int sstrnleft;
|
|---|
| 227 | int herefd/* = -1 */;
|
|---|
| 228 |
|
|---|
| 229 | /* memalloc.c */
|
|---|
| 230 | struct stack_block stackbase;
|
|---|
| 231 | struct stack_block *stackp/* = &stackbase*/;
|
|---|
| 232 | struct stackmark *markp;
|
|---|
| 233 |
|
|---|
| 234 | /* myhistedit.h */
|
|---|
| 235 | int displayhist;
|
|---|
| 236 | #ifndef SMALL
|
|---|
| 237 | History *hist;
|
|---|
| 238 | EditLine *el;
|
|---|
| 239 | #endif
|
|---|
| 240 |
|
|---|
| 241 | /* output.h */
|
|---|
| 242 | struct output output;
|
|---|
| 243 | struct output errout;
|
|---|
| 244 | struct output memout;
|
|---|
| 245 | struct output *out1;
|
|---|
| 246 | struct output *out2;
|
|---|
| 247 |
|
|---|
| 248 | /* output.c */
|
|---|
| 249 | #define OUTBUFSIZ BUFSIZ
|
|---|
| 250 | #define MEM_OUT -3 /**< output to dynamically allocated memory */
|
|---|
| 251 |
|
|---|
| 252 | /* options.h */
|
|---|
| 253 | struct optent optlist[NOPTS];
|
|---|
| 254 | char *minusc; /**< argument to -c option */
|
|---|
| 255 | char *arg0; /**< $0 */
|
|---|
| 256 | struct shparam shellparam; /**< $@ */
|
|---|
| 257 | char **argptr; /**< argument list for builtin commands */
|
|---|
| 258 | char *optionarg; /**< set by nextopt */
|
|---|
| 259 | char *optptr; /**< used by nextopt */
|
|---|
| 260 |
|
|---|
| 261 | /* parse.h */
|
|---|
| 262 | int tokpushback;
|
|---|
| 263 | int whichprompt; /**< 1 == PS1, 2 == PS2 */
|
|---|
| 264 |
|
|---|
| 265 | /* parser.c */
|
|---|
| 266 | int noalias/* = 0*/;/**< when set, don't handle aliases */
|
|---|
| 267 | struct heredoc *heredoclist; /**< list of here documents to read */
|
|---|
| 268 | int parsebackquote; /**< nonzero if we are inside backquotes */
|
|---|
| 269 | int doprompt; /**< if set, prompt the user */
|
|---|
| 270 | int needprompt; /**< true if interactive and at start of line */
|
|---|
| 271 | int lasttoken; /**< last token read */
|
|---|
| 272 | char *wordtext; /**< text of last word returned by readtoken */
|
|---|
| 273 | int checkkwd; /**< 1 == check for kwds, 2 == also eat newlines */
|
|---|
| 274 | struct nodelist *backquotelist;
|
|---|
| 275 | union node *redirnode;
|
|---|
| 276 | struct heredoc *heredoc;
|
|---|
| 277 | int quoteflag; /**< set if (part of) last token was quoted */
|
|---|
| 278 | int startlinno; /**< line # where last token started */
|
|---|
| 279 |
|
|---|
| 280 | /* redir.c */
|
|---|
| 281 | struct redirtab *redirlist;
|
|---|
| 282 | int fd0_redirected/* = 0*/;
|
|---|
| 283 |
|
|---|
| 284 | /* trap.h */
|
|---|
| 285 | int pendingsigs; /**< indicates some signal received */
|
|---|
| 286 |
|
|---|
| 287 | /* trap.c */
|
|---|
| 288 | char gotsig[NSIG]; /**< indicates specified signal received */
|
|---|
| 289 | char *trap[NSIG+1]; /**< trap handler commands */
|
|---|
| 290 | char sigmode[NSIG]; /**< current value of signal */
|
|---|
| 291 |
|
|---|
| 292 | /* var.h */
|
|---|
| 293 | struct localvar *localvars;
|
|---|
| 294 | struct var vatty;
|
|---|
| 295 | struct var vifs;
|
|---|
| 296 | struct var vmail;
|
|---|
| 297 | struct var vmpath;
|
|---|
| 298 | struct var vpath;
|
|---|
| 299 | #ifdef _MSC_VER
|
|---|
| 300 | struct var vpath2;
|
|---|
| 301 | #endif
|
|---|
| 302 | struct var vps1;
|
|---|
| 303 | struct var vps2;
|
|---|
| 304 | struct var vps4;
|
|---|
| 305 | #ifndef SMALL
|
|---|
| 306 | struct var vterm;
|
|---|
| 307 | struct var vhistsize;
|
|---|
| 308 | #endif
|
|---|
| 309 | struct var voptind;
|
|---|
| 310 | #ifdef PC_OS2_LIBPATHS
|
|---|
| 311 | struct var libpath_vars[4];
|
|---|
| 312 | #endif
|
|---|
| 313 | #ifdef SMALL
|
|---|
| 314 | # define VTABSIZE 39
|
|---|
| 315 | #else
|
|---|
| 316 | # define VTABSIZE 517
|
|---|
| 317 | #endif
|
|---|
| 318 | struct var *vartab[VTABSIZE];
|
|---|
| 319 |
|
|---|
| 320 | /* builtins.h */
|
|---|
| 321 |
|
|---|
| 322 | /* bltin/test.c */
|
|---|
| 323 | char **t_wp;
|
|---|
| 324 | struct t_op const *t_wp_op;
|
|---|
| 325 |
|
|---|
| 326 | };
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 | extern shinstance *sh_create_root_shell(shinstance *, int, char **);
|
|---|
| 330 |
|
|---|
| 331 | /* environment & pwd.h */
|
|---|
| 332 | char *sh_getenv(shinstance *, const char *);
|
|---|
| 333 | char **sh_environ(shinstance *);
|
|---|
| 334 | const char *sh_gethomedir(shinstance *, const char *);
|
|---|
| 335 |
|
|---|
| 336 | /* signals */
|
|---|
| 337 | #define SH_SIG_UNK ((shsig_t)(intptr_t)-199)
|
|---|
| 338 | #define SH_SIG_DFL ((shsig_t)SIG_DFL)
|
|---|
| 339 | #define SH_SIG_IGN ((shsig_t)SIG_IGN)
|
|---|
| 340 | #define SH_SIG_ERR ((shsig_t)SIG_ERR)
|
|---|
| 341 | #ifdef _MSC_VER
|
|---|
| 342 | # define SIG_BLOCK 1
|
|---|
| 343 | # define SIG_UNBLOCK 2
|
|---|
| 344 | # define SIG_SETMASK 3
|
|---|
| 345 | # define SIGHUP 5
|
|---|
| 346 | # define SIGQUIT 9
|
|---|
| 347 | # define SIGPIPE 12
|
|---|
| 348 | # define SIGTTOU 17
|
|---|
| 349 | # define SIGTSTP 18
|
|---|
| 350 | # define SIGTTIN 19
|
|---|
| 351 | # define SIGCONT 20
|
|---|
| 352 | # define sys_siglist sys_signame
|
|---|
| 353 | #endif /* _MSC_VER */
|
|---|
| 354 | #ifdef __sun__
|
|---|
| 355 | # define sys_siglist _sys_siglist
|
|---|
| 356 | #endif
|
|---|
| 357 | #ifndef HAVE_SYS_SIGNAME
|
|---|
| 358 | extern char sys_signame[NSIG][16];
|
|---|
| 359 | #endif
|
|---|
| 360 |
|
|---|
| 361 | int sh_sigaction(shinstance *, int, const struct shsigaction *, struct shsigaction *);
|
|---|
| 362 | shsig_t sh_signal(shinstance *, int, shsig_t);
|
|---|
| 363 | int sh_siginterrupt(shinstance *, int, int);
|
|---|
| 364 | void sh_sigemptyset(shsigset_t *);
|
|---|
| 365 | int sh_sigfillset(shsigset_t *);
|
|---|
| 366 | void sh_sigaddset(shsigset_t *, int);
|
|---|
| 367 | void sh_sigdelset(shsigset_t *, int);
|
|---|
| 368 | int sh_sigismember(shsigset_t *, int);
|
|---|
| 369 | int sh_sigprocmask(shinstance *, int, shsigset_t const *, shsigset_t *);
|
|---|
| 370 | void sh_abort(shinstance *) __attribute__((__noreturn__));
|
|---|
| 371 | void sh_raise_sigint(shinstance *);
|
|---|
| 372 | int sh_kill(shinstance *, pid_t, int);
|
|---|
| 373 | int sh_killpg(shinstance *, pid_t, int);
|
|---|
| 374 |
|
|---|
| 375 | /* times */
|
|---|
| 376 | #include <time.h>
|
|---|
| 377 | #ifdef _MSC_VER
|
|---|
| 378 | typedef struct shtms
|
|---|
| 379 | {
|
|---|
| 380 | clock_t tms_utime;
|
|---|
| 381 | clock_t tms_stime;
|
|---|
| 382 | clock_t tms_cutime;
|
|---|
| 383 | clock_t tms_cstime;
|
|---|
| 384 | } shtms;
|
|---|
| 385 | #else
|
|---|
| 386 | # include <sys/times.h>
|
|---|
| 387 | typedef struct tms shtms;
|
|---|
| 388 | #endif
|
|---|
| 389 | clock_t sh_times(shinstance *, shtms *);
|
|---|
| 390 | int sh_sysconf_clk_tck(void);
|
|---|
| 391 |
|
|---|
| 392 | /* wait / process */
|
|---|
| 393 | #ifdef _MSC_VER
|
|---|
| 394 | # include <process.h>
|
|---|
| 395 | # define WNOHANG 1 /* Don't hang in wait. */
|
|---|
| 396 | # define WUNTRACED 2 /* Tell about stopped, untraced children. */
|
|---|
| 397 | # define WCONTINUED 4 /* Report a job control continued process. */
|
|---|
| 398 | # define _W_INT(w) (*(int *)&(w)) /* Convert union wait to int. */
|
|---|
| 399 | # define WCOREFLAG 0200
|
|---|
| 400 | # define _WSTATUS(x) (_W_INT(x) & 0177)
|
|---|
| 401 | # define _WSTOPPED 0177 /* _WSTATUS if process is stopped */
|
|---|
| 402 | # define WIFSTOPPED(x) (_WSTATUS(x) == _WSTOPPED)
|
|---|
| 403 | # define WSTOPSIG(x) (_W_INT(x) >> 8)
|
|---|
| 404 | # define WIFSIGNALED(x) (_WSTATUS(x) != 0 && !WIFSTOPPED(x) && !WIFCONTINUED(x)) /* bird: made GLIBC tests happy. */
|
|---|
| 405 | # define WTERMSIG(x) (_WSTATUS(x))
|
|---|
| 406 | # define WIFEXITED(x) (_WSTATUS(x) == 0)
|
|---|
| 407 | # define WEXITSTATUS(x) (_W_INT(x) >> 8)
|
|---|
| 408 | # define WIFCONTINUED(x) (x == 0x13) /* 0x13 == SIGCONT */
|
|---|
| 409 | # define WCOREDUMP(x) (_W_INT(x) & WCOREFLAG)
|
|---|
| 410 | # define W_EXITCODE(ret, sig) ((ret) << 8 | (sig))
|
|---|
| 411 | # define W_STOPCODE(sig) ((sig) << 8 | _WSTOPPED)
|
|---|
| 412 | #else
|
|---|
| 413 | # include <sys/wait.h>
|
|---|
| 414 | #endif
|
|---|
| 415 | pid_t sh_fork(shinstance *);
|
|---|
| 416 | pid_t sh_waitpid(shinstance *, pid_t, int *, int);
|
|---|
| 417 | void sh__exit(shinstance *, int) __attribute__((__noreturn__));
|
|---|
| 418 | int sh_execve(shinstance *, const char *, const char * const*, const char * const *);
|
|---|
| 419 | uid_t sh_getuid(shinstance *);
|
|---|
| 420 | uid_t sh_geteuid(shinstance *);
|
|---|
| 421 | gid_t sh_getgid(shinstance *);
|
|---|
| 422 | gid_t sh_getegid(shinstance *);
|
|---|
| 423 | pid_t sh_getpid(shinstance *);
|
|---|
| 424 | pid_t sh_getpgrp(shinstance *);
|
|---|
| 425 | pid_t sh_getpgid(shinstance *, pid_t);
|
|---|
| 426 | int sh_setpgid(shinstance *, pid_t, pid_t);
|
|---|
| 427 |
|
|---|
| 428 | /* tc* */
|
|---|
| 429 | pid_t sh_tcgetpgrp(shinstance *, int);
|
|---|
| 430 | int sh_tcsetpgrp(shinstance *, int, pid_t);
|
|---|
| 431 |
|
|---|
| 432 | /* sys/resource.h */
|
|---|
| 433 | #ifdef _MSC_VER
|
|---|
| 434 | typedef int64_t shrlim_t;
|
|---|
| 435 | typedef struct shrlimit
|
|---|
| 436 | {
|
|---|
| 437 | shrlim_t rlim_cur;
|
|---|
| 438 | shrlim_t rlim_max;
|
|---|
| 439 | } shrlimit;
|
|---|
| 440 | # define RLIMIT_CPU 0
|
|---|
| 441 | # define RLIMIT_FSIZE 1
|
|---|
| 442 | # define RLIMIT_DATA 2
|
|---|
| 443 | # define RLIMIT_STACK 3
|
|---|
| 444 | # define RLIMIT_CORE 4
|
|---|
| 445 | # define RLIMIT_RSS 5
|
|---|
| 446 | # define RLIMIT_MEMLOCK 6
|
|---|
| 447 | # define RLIMIT_NPROC 7
|
|---|
| 448 | # define RLIMIT_NOFILE 8
|
|---|
| 449 | # define RLIMIT_SBSIZE 9
|
|---|
| 450 | # define RLIMIT_VMEM 10
|
|---|
| 451 | # define RLIM_NLIMITS 11
|
|---|
| 452 | # define RLIM_INFINITY (0x7fffffffffffffffLL)
|
|---|
| 453 | #else
|
|---|
| 454 | typedef rlim_t shrlim_t;
|
|---|
| 455 | typedef struct rlimit shrlimit;
|
|---|
| 456 | #endif
|
|---|
| 457 | int sh_getrlimit(shinstance *, int, shrlimit *);
|
|---|
| 458 | int sh_setrlimit(shinstance *, int, const shrlimit *);
|
|---|
| 459 |
|
|---|
| 460 |
|
|---|
| 461 | #ifdef DEBUG
|
|---|
| 462 | # define TRACE2(param) trace param
|
|---|
| 463 | # define TRACE2V(param) tracev param
|
|---|
| 464 | #else
|
|---|
| 465 | # define TRACE2(param)
|
|---|
| 466 | # define TRACE2V(param)
|
|---|
| 467 | #endif
|
|---|
| 468 |
|
|---|
| 469 | #endif
|
|---|