2011/1/7 Hexchain Tong <richard0053(a)gmail.com>:
Hi all,
最近在写一个类似于 OI 评测机的程序,由用户提交代码,处理后编译为目标程序执行。现在的想法是由一个程序 fork 出子进程,在子进程里
chroot 后执行目标程序,主程序卡时间等待子程序退出(主进程退出时会按 pid 杀掉 fork
出来的子进程)。但是目标程序的这样一段代码会让自身不被杀掉:
extern int kill(int, int);
extern int getppid(void);
extern int pause(void);
int main() {
kill(getppid(), 9);
pause();
return 0;
}
在 USACO (http://ace.delos.com/usacogate) 上测试会出现 Bad syscall 的错误,请问这种对
syscall 的限制是怎么做到的?如果有更好的方法,请告诉我,谢谢!
--
Hexchain Tong
----------------------------------------------------
Profile:
https://www.google.com/profiles/richard0053
Twitter: @Hexc4l
Facebook: hexchain(a)facebook.com
Mail: richard0053(a)gmail.com
可能没说清楚……假设用户代码编译出来的程序是 A,执行 fork/chroot 的那个程序是 F,正常情况下 F 会 fork 出子进程后
exec A,上面的代码则会导致 F 死掉而 A 继续运行。
--
Hexchain Tong
----------------------------------------------------
Profile:
https://www.google.com/profiles/richard0053
Twitter: @Hexc4l
Facebook: hexchain(a)facebook.com
Mail: richard0053(a)gmail.com