没有线程的比赛条件?

Kev*_*ith 3 c race-condition

假设我有:sample.c

int main (...) {

  char str*;

  get s through user input

  test(str);

  return 0;

}

void test (str) {

   copy str to new file 

   change file permissions on new file

   close file

}
Run Code Online (Sandbox Code Playgroud)

因为我的main()方法中没有线程,所以不存在竞争条件.真的吗?

Pet*_* G. 8

存在一种竞争条件,即用户可以在更改"新文件"的权限之前立即交换"新文件".这是(是?)常用的安全漏洞.

我只是看到Neil Butterworth有一个相关的想法.


小智 6

有可能发生竞争 - 两个用户可以同时运行您的程序.