Current-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: Locking processes against being killed when low on memory
On Fri, 22 Feb 2008 15:34:52 +0000
Patrick Welche <prlw1%newn.cam.ac.uk@localhost> wrote:
> On Fri, Feb 22, 2008 at 12:14:48PM +0000, Steven M. Bellovin wrote:
> > I'll try, but with no message and no dump that isn't easy...
>
> Post the program? (Have serial console...)
It's a laptop with no serial port. It's also my only amd64 machine...
As for the code -- attached. It's nothing fancy....
>
> Patrick
--Steve Bellovin, http://www.cs.columbia.edu/~smb
#include <stdio.h>
#include <stdlib.h>
const char *_malloc_options = "Z";
#define chunk ((size_t) 1024*1024)
main(int argc, char *argv[])
{
void *p, *lp = NULL;
int i = 0;
int lim = 2560;
if (argc > 1) lim = atoi(argv[1]);
printf("Starting: %d...\n", lim);
fflush(stdout);
while (i < lim && (p = malloc(chunk)) != NULL) {
lp = p;
i++;
}
if (lp) free(lp);
printf("Done: %d\n", i);
return 0;
}
Home |
Main Index |
Thread Index |
Old Index