From: kimura@musashi.mri.co.jp (Kazushi Kimura)
Newsgroups: fj.sys.hp
Subject: Re: tcsh can limit core!
Date: 17 Dec 92 08:47:50 GMT
Distribution: fj
Organization: Mitsubishi Research Institute, Inc., Tokyo, Japan.
In-reply-to: kimura@musashi.mri.co.jp's message of 15 Dec 92 04:59:21 GMT


$@$-$`$i$+$:$7!w#M#R#I$G$9!#(J

$@!t(Jcomp.sys.hp $@$r=&$$FI$_$7$F$$$k$H(J core dump $@$NOC$,;~!9$G$F(J$@$-$F(J
$@!t!V$&$A$N%^%7%s$O(J 50Mbyte $@$N(J core $@$rEG$$$?!W$H$+!"!V26$N$H$3$J$s$+(J
$@!t(J 30Mbyte $@$N(J core $@$rEG$$$?(J Program $@$r(J gdb $@$K?)$o$;$h$&$H$7$?$i(J
$@!t%/%i%C%7%e$7$F(J 450Mbyte $@$N(J core $@$,=PMh$?!*!W$J$s$F(J core $@<+K}!)$r(J
$@!t$7$F$?$j$7$^$9!#(J

$@$5$F!"K\Bj$G$9!#(J

> comp.sys.hp $@$r$N$>$$$F$$$?$i!":G?7HG$N(J tcsh $@$O(J core $@$N(J limit 
> $@$,$G$-$k$H=q$$$F$"$j$^$7$?!#(J

$@$A$J$_$K!"0J2<$,$=$N5-;v$N%X%C%@!<$G$9!#(J
| From: stolcke@ICSI.Berkeley.EDU (Andreas Stolcke)
| Newsgroups: comp.sys.hp,comp.unix.questions
| Subject: Re: limiting coredump size
| Message-ID: <1gdvo7INN50d@agate.berkeley.edu>
| Date: 13 Dec 92 00:22:31 GMT

$@$3$N7o$K$D$$(J$@$F>>2<!wD;5o8&(J.$@>pJs9)3X2J(J.$@:eBg$5$s$,D4$Y$F2<$5$$$^$7$?!#(J
$@$I$&$b$"$j$,$H$&$4$6$$$^$7$?!#(J

$@$=$N7kO@$O!D(J

tcsh-6.03 & HP-UX8.0 $@$J$i(J limit $@$,;H$($k!#(J
tcsh-6.03 & HP-UX7.0 $@$O$@$a!#(J

tcsh-6.02 $@$O$@$a!#$7$+$7!D(J

$@0J2<$N5-=R$,@($$$N$G$=$N$^$^0zMQ$7$^$9(J :-) $@!J5v2D$OF@$F$"$j$^$9!K(J

$@!A!A!A!!0zMQ!J0lItJT=8$"$j!K!!!A(J$@!A!A(J
$@$H!"$$$&$3$H$O!"(J6.03 $@$N%=!<%9$,<j$KF~$i$J$$$H!"L5M}$G$9$M(J :) $@$8$c!"2?(J
$@$N2r7h$K$b$J$i$J$$$N$G!"$A(J$@$g$3$C$HD4$Y$F$_$^$7$?!#(J

BSD resource limit $@$N%3!<%I$O$=$b$=$b(J 6.02 $@$K$9$G$K$"$j!J$@$+$i(J sun $@$H(J
$@$+$O(J$@Ev$?$jA0$N$h$&$K$G$-$k!KAa$$OC$7$,$3$N%3!<%I$r;H$($k$h$&$K$7$F$d$l(J
$@$P$$$$$3$H$K$J$j$^$9!#(J

6.03 $@$N(J Fixes $@$r8+$k$H(J
---
45. 6.02.06 8/14/92 
44. Separated limit stuff from BSDTIMES and added BSDLIMIT
---
$@$C$F=q$$$F$"$j$^$9$+$i!"(JBSDLIMIT $@$H$$$&(J define $@$r(J 6.03 $@$N%=!<%9$r8+$J(J
$@$,$i:n$C$F$d$l$P2?$H$+$J$j$=$&$G(J$@$9!#(J

$@$G!";n$7$K(J 6.03 $@$N%=!<%9$r8+$J$,$i(J patch $@$r$7$F$_$?$H$3$m(J
	$@!V$A$c$s$H$&$4$$$F$k$h$&$@!W(J
$@$H$$$&$3(J$@$H$,$o$+$j$^$7$?!#<B:]$K;H$C$F$$$k$o$1$G$O$J$$!J(J6.03 $@$,F0$$$F(J
$@$$$k$+$i!K$G$9$,!"$H$j$"$($:(J compile $@$7(J$@$FF0$$$F$$$k$N$O3N$+$G$9!#$3$A(J
$@$i$N4D6-$O(J
	HP-UX 8.07 + HP9000 series 710/720
$@$G$9!#(J

$@0J2<$K(J patch $@$r(J$@$D$1$^$9!#$h$m$7$1$l$P@'Hs$d$C$F$_$F2<$5$$!#$J$*!"$"$/(J
$@$^$G(J tcsh-6.03 $@$N%=!<%9$r8+$J$,$i:n$C$?(J quick patch $@$G$9$N$G!"F0:n@UG$(J
$@$O0l@Z$H$l$^$;$s!#$?$@!"2?$H$J$/$3$l$GBg>fIW$8$c$J$$$N!)$/$i$$$K;W$C$F(J
$@2<$5$$(J$@!#(J

*** MAKOTO Matsushita  <matusita@ics.osaka-u.ac.jp> ***
Dept. of Information and Computer Sciences, Osaka University, Osaka, JAPAN

---- $@$3$3$+$i(J ----
*** config/config.hpux.dist	Wed Dec 16 18:03:52 1992
--- config/config.hpux	Wed Dec 16 19:31:30 1992
***************
*** 71,76 ****
--- 71,81 ----
  #undef BSDTIMES
  
  /*
+  * BSDLIMIT	You have BSD-style resource limit stuff (getrlimit/setrlimit)
+  */
+ #define BSDLIMIT
+ 
+ /*
   * BSDNICE	Your system uses setpriority() instead of nice, to
   *		change a processes scheduling priority
   */
*** sh.decls.h.dist	Wed Dec 16 19:04:04 1992
--- sh.decls.h	Wed Dec 16 19:04:38 1992
***************
*** 264,272 ****
  extern	void		  pcsecs	__P((time_t));
  # endif /* !POSIX */
  #endif /* BSDTIMES */
! #ifdef RLIMIT_CPU
  extern	void		  psecs		__P((long));
! #endif /* RLIMIT_CPU */
  extern	int		  putpure	__P((int));
  extern	int		  putraw	__P((int));
  extern	void		  xputchar	__P((int));
--- 264,272 ----
  extern	void		  pcsecs	__P((time_t));
  # endif /* !POSIX */
  #endif /* BSDTIMES */
! #ifdef BSDLIMIT
  extern	void		  psecs		__P((long));
! #endif /* BSDLIMIT */
  extern	int		  putpure	__P((int));
  extern	int		  putraw	__P((int));
  extern	void		  xputchar	__P((int));
*** sh.func.c.dist	Wed Dec 16 18:08:39 1992
--- sh.func.c	Wed Dec 16 19:13:13 1992
***************
*** 1388,1394 ****
  }
  
  #ifndef HAVENOLIMIT
! # ifndef BSDTIMES
     typedef long RLIM_TYPE;
  #  ifndef RLIM_INFINITY
  #   ifndef _MINIX
--- 1388,1394 ----
  }
  
  #ifndef HAVENOLIMIT
! # ifndef BSDLIMIT
     typedef long RLIM_TYPE;
  #  ifndef RLIM_INFINITY
  #   ifndef _MINIX
***************
*** 1404,1414 ****
  #  else /* aiws */
  #   define toset(a) ((a) + 1)
  #  endif /* aiws */
! # else /* BSDTIMES */
     typedef int RLIM_TYPE;
! # endif /* BSDTIMES */
  
  
  struct limits limits[] = 
  {
  # ifdef RLIMIT_CPU
--- 1404,1431 ----
  #  else /* aiws */
  #   define toset(a) ((a) + 1)
  #  endif /* aiws */
! # else /* BSDLIMIT */
     typedef int RLIM_TYPE;
! # endif /* BSDLIMIT */
  
  
+ # if defined(hpux) && defined(BSDLIMIT)
+ /* Yes hpux8.0 has limits but <sys/resource.h> does not make them public */
+ /* Yes, we could have defined _KERNEL, and -I/etc/conf/h, but is that better? */
+ #  ifndef RLIMIT_CPU
+ #   define RLIMIT_CPU		0
+ #   define RLIMIT_FSIZE		1
+ #   define RLIMIT_DATA		2
+ #   define RLIMIT_STACK		3
+ #   define RLIMIT_CORE		4
+ #   define RLIMIT_RSS		5
+ #   define RLIMIT_NOFILE	6
+ #  endif /* RLIMIT_CPU */
+ #  ifndef RLIM_INFINITY
+ #   define RLIM_INFINITY	0x7fffffff
+ #  endif /* RLIM_INFINITY */
+ # endif /* hpux && BSDLIMIT */
+ 
  struct limits limits[] = 
  {
  # ifdef RLIMIT_CPU
***************
*** 1677,1699 ****
      register struct limits *lp;
      Char    hard;
  {
! # ifdef BSDTIMES
      struct rlimit rlim;
! # endif /* BSDTIMES */
      RLIM_TYPE limit;
  
      xprintf("%s \t", lp->limname);
  
! # ifndef BSDTIMES
      limit = ulimit(lp->limconst, 0);
  #  ifdef aiws
      if (lp->limconst == RLIMIT_DATA)
  	limit -= 0x20000000;
  #  endif /* aiws */
! # else /* BSDTIMES */
      (void) getrlimit(lp->limconst, &rlim);
      limit = hard ? rlim.rlim_max : rlim.rlim_cur;
! # endif /* BSDTIMES */
  
      if (limit == RLIM_INFINITY)
  	xprintf("unlimited");
--- 1694,1716 ----
      register struct limits *lp;
      Char    hard;
  {
! # ifdef BSDLIMIT
      struct rlimit rlim;
! # endif /* BSDLIMIT */
      RLIM_TYPE limit;
  
      xprintf("%s \t", lp->limname);
  
! # ifndef BSDLIMIT
      limit = ulimit(lp->limconst, 0);
  #  ifdef aiws
      if (lp->limconst == RLIMIT_DATA)
  	limit -= 0x20000000;
  #  endif /* aiws */
! # else /* BSDLIMIT */
      (void) getrlimit(lp->limconst, &rlim);
      limit = hard ? rlim.rlim_max : rlim.rlim_cur;
! # endif /* BSDLIMIT */
  
      if (limit == RLIM_INFINITY)
  	xprintf("unlimited");
***************
*** 1752,1762 ****
      Char    hard;
      RLIM_TYPE limit;
  {
! # ifdef BSDTIMES
      struct rlimit rlim;
  
      (void) getrlimit(lp->limconst, &rlim);
  
      if (hard)
  	rlim.rlim_max = limit;
      else if (limit == RLIM_INFINITY && geteuid() != 0)
--- 1769,1784 ----
      Char    hard;
      RLIM_TYPE limit;
  {
! # ifdef BSDLIMIT
      struct rlimit rlim;
  
      (void) getrlimit(lp->limconst, &rlim);
  
+ #  ifdef hpux
+     /* Even though hpux has setrlimit(), it expects fsize in 512 byte blocks */
+     if (limit != RLIM_INFINITY && lp->limconst == RLIMIT_FSIZE)
+ 	limit /= 512;
+ #  endif /* hpux */
      if (hard)
  	rlim.rlim_max = limit;
      else if (limit == RLIM_INFINITY && geteuid() != 0)
***************
*** 1765,1771 ****
  	rlim.rlim_cur = limit;
  
      if (setrlimit(lp->limconst, &rlim) < 0) {
! # else /* BSDTIMES */
      if (limit != RLIM_INFINITY && lp->limconst == RLIMIT_FSIZE)
  	limit /= 512;
  # ifdef aiws
--- 1787,1793 ----
  	rlim.rlim_cur = limit;
  
      if (setrlimit(lp->limconst, &rlim) < 0) {
! # else /* BSDLIMIT */
      if (limit != RLIM_INFINITY && lp->limconst == RLIMIT_FSIZE)
  	limit /= 512;
  # ifdef aiws
***************
*** 1773,1779 ****
  	limit += 0x20000000;
  # endif /* aiws */
      if (ulimit(toset(lp->limconst), limit) < 0) {
! # endif /* BSDTIMES */
  	xprintf("%s: %s: Can't %s%s limit\n", bname, lp->limname,
  		limit == RLIM_INFINITY ? "remove" : "set",
  		hard ? " hard" : "");
--- 1795,1801 ----
  	limit += 0x20000000;
  # endif /* aiws */
      if (ulimit(toset(lp->limconst), limit) < 0) {
! # endif /* BSDLIMIT */
  	xprintf("%s: %s: Can't %s%s limit\n", bname, lp->limname,
  		limit == RLIM_INFINITY ? "remove" : "set",
  		hard ? " hard" : "");
*** sh.print.c.dist	Wed Dec 16 18:49:04 1992
--- sh.print.c	Wed Dec 16 19:06:35 1992
***************
*** 52,58 ****
   * C Shell
   */
  
! #ifdef RLIMIT_CPU
  void
  psecs(l)
      long    l;
--- 52,58 ----
   * C Shell
   */
  
! #ifdef BSDLIMIT
  void
  psecs(l)
      long    l;
--- $@$3$3$^$G(J  ---
$@!A!A!A!!0zMQ$*$o$j!!!A!A!A(J
--
$@"v!!LZB<!!(J$@?t;K!!!J3t!K;0I)Am9g8&5f=j(J    JUNET:kimura@mri.co.jp
                                        NIFTY:TBC00726