crash.c

来自「This a framework to test new ideas in tr」· C语言 代码 · 共 38 行

C
38
字号
/** * crash.c  - make RTLinux crash as simple as possible...  */#include <pthread.h>#include <stdio.h>#define BUF_LEN 256void *start_it( void *arg ) {  FILE *f;  int i=0;  char str[BUF_LEN] = "This is a test\n";  while (1) {    if ( ( f = fopen( "/tmp/test", "w" ) ) ) {      //fprintf( f, "hi\n" );      printf( "created file %i %p\n", ++i, f );      fwrite( str, BUF_LEN, 1, f );      fclose( f );    } else {      return NULL;    }  }  return NULL;}pthread_t start_t;int main(void) {  if ( pthread_create( &start_t, NULL, start_it, NULL ) ) {    printf( "Couldn't init thread\n" );    return -1;  }  pthread_join( start_t, NULL );  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?