Kernel/VTerm - "Fix" wrapping issue in VTerm (why was old behavior there?)
[tpg/acess2.git] / Usermode / Applications / bomb_src / main.c
1 /*
2  * Acess2 Stress Tester
3  */
4 #include <acess/sys.h>
5 #include <stdlib.h>
6 #include <stdio.h>
7
8  //int  giMallocSize = 1024;
9  int    gbOverrideCOW = 0;
10  int    gbForkBomb = 0;
11
12 /**
13  * \fn int main(int argc, char *argv[])
14  * \brief Entrypoint
15  */
16 int main(int argc, char *argv[])
17 {
18          int    i;
19         
20         for( i = 1; i < argc; i ++ )
21         {
22                 if( argv[i][0] != '-' ) {
23                         //PrintUsage(argv[0]);
24                         return 1;
25                 }
26                 
27                 switch( argv[i][1] )
28                 {
29                 case 'f':
30                         gbForkBomb = 1;
31                         break;
32                 case 'c':
33                         gbOverrideCOW = 1;
34                         break;
35                 //case 'm':
36                 //      giMallocSize = atoi(argv[++i]);
37                 //      break;
38                 case 'h':
39                         //PrintHelp(argv[0]);
40                         return 0;
41                 }
42         }
43
44         if( gbForkBomb )
45         {
46                 for(;;) _SysClone(CLONE_VM, 0);
47         }
48         else {
49                 for(;;)
50                 {
51                         const int stackSize = 512-16; 
52                         const int stackOffset = 65; 
53                         char *stack = calloc(1, stackSize);
54                          int    tid;
55                         if( !stack ) {
56                                 printf("Outta heap space!\n");
57                                 return 0;
58                         }
59                         tid = _SysClone(0, stack+stackSize-stackOffset);
60                         //_SysDebug("tid = %i", tid);
61                         if( tid == 0 )
62                         {
63                                 // Sleep forever (TODO: Fix up the stack so it can nuke)
64                                 for(;;) _SysWaitEvent(THREAD_EVENT_SIGNAL);
65                         }
66                         if( tid < 0 ) {
67                                 printf("Clone failed\n");
68                                 return 0;
69                         }
70                 }
71         }
72
73         printf("RETURN!?\n");
74         return 0;
75 }

UCC git Repository :: git.ucc.asn.au