Why is rand() not so random after fork?

前端 未结 7 1147
星月不相逢
星月不相逢 2020-12-03 22:05
#include 
#include 
#include 
#include 

int main() {
    int i =10;
    /* initialize random seed:  */
         


        
7条回答
  •  失恋的感觉
    2020-12-03 22:43

    If your code is running fast enough, srand() might be seeded with the exact same time for each fork. time() only changes every second.

提交回复
热议问题