📄 cloning.c
字号:
/*************************************************************************** cloning.c - description ------------------- begin : Mon Jan 31 2000 copyright : (C) 2000 by 豶n E. Hansen email : oe.hansen@gamma.telenordia.se ***************************************************************************//*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/#include <sched.h>#include <unistd.h>#include <malloc.h>#include <errno.h>#include "cloning.h"//// There is a huge problem with the use of CLONE under linux,// and it has to do with the use of the STACK. In this version// the stack pages are memory pages, taken by the user. The// stack, being top-down ordered in ix86 systems, can easyly run// over the users memory space.//beginthread(int (*_fn)(void *),void *_sp,void *_arg){ char *sp = _sp; int size=8*STACK_PAGE_SIZE; int pid; if ( sp == NULL ) { sp = malloc(size); if( sp ) sp += size; } if (sp == NULL) return -(errno = ENOMEM); pid = clone(_fn, sp, CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND, _arg); if (pid < 0) { if ( _sp == NULL ) free(sp); sp = NULL; } return pid;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -