fork download
  1. #define _BSD_SOURCE
  2. #include <sys/mman.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int main( int argc, char **argv )
  7. {
  8. char *p;
  9. char *buf = mmap( ( void * ) 0, 4096,
  10. PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED | MAP_ANON, -1, 0 );
  11. if (buf == MAP_FAILED) perror("mmap");
  12. printf( "buf: %p\n", buf );
  13. p = strncpy( buf, "string", strlen( "string" ) );
  14. printf( "p: %p\n", p );
  15. printf( "NULL: %p\n", NULL );
  16. return( 0 );
  17. }
  18.  
Runtime error #stdin #stdout #stderr 0s 2112KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
mmap: Operation not permitted