Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!uunet!munnari!natmlab!dmscanb!dmsadel!augean!idall From: idall@augean.OZ (Ian Dall) Newsgroups: comp.unix.wizards Subject: Peculiar behaviour of ulimit(2) Message-ID: <185@augean.OZ> Date: Mon, 29-Jun-87 02:12:27 EDT Article-I.D.: augean.185 Posted: Mon Jun 29 02:12:27 1987 Date-Received: Sat, 4-Jul-87 22:36:57 EDT Reply-To: idall@augean.OZ (Ian Dall) Distribution: world Organization: Engineering Faculty, University of Adelaide, Australia Lines: 64 On my SysV.2.2 system ( National Semiconductors port for the ICM-3216 ) the ulimit(2) system call seems to misbehave. The man entry says it returns the maximum break value possible. For this system 8MB is reasonable since it has 16MB virtual address space half of which is stack space. Sure enough ulimit initially does return 8MB. However, after doing a brk(n) where n is anything greater than 20000 hex, ulimit returns 20000 hex. If n is less than 20000 hex it returns 8MB. This is illustrated by the staggeringly useful program as follows: #include main(){ long foo; extern long ulimit(); extern char *sbrk(); extern int brk(); char *foop; foo = ulimit(3, 0l); printf("Makimum break value %d (%X)\n",foo , foo); foop = (char *) 0x7E0000; printf ("Set break value to %d (%X)\n",foop,foop); brk(foop); foo = ulimit(3, 0l); printf("Makimum break value %d (%X)\n",foo , foo); foop = (char *) 0x50000; printf ("Set break value to %d (%X)\n",foop,foop); brk(foop); foo = ulimit(3, 0l); printf("Makimum break value %d (%X)\n",foo , foo); foop = (char *) 0x18000; printf ("Set break value to %d (%X)\n",foop,foop); brk(foop); foo = ulimit(3, 0l); printf("Makimum break value %d (%X)\n",foo , foo); exit(); } Which results in: Makimum break value 8257536 (7E0000) Set break value to 8257536 (7E0000) Makimum break value 131072 (20000) Set break value to 327680 (50000) Makimum break value 131072 (20000) Set break value to 98304 (18000) Makimum break value 8257536 (7E0000) The question is: Is this a bug or a feature? In the unlikely event that it's a feature, what is the significance of 20000 hex? If it's a bug, is it generic to SysV or just this port of it? Ian Dall idall@augean.oz