<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          LibChildControl作業(yè)控制程序

          聯(lián)合創(chuàng)作 · 2023-09-29 15:22

          LibChildControl 能創(chuàng)建一個(gè)線程來管理子進(jìn)程,并且在失敗的時(shí)候重啟他們。

          使用示例:

          int child_process (void *data)
          {
              int id = *(int *)data;
              int delay = (id + 1) * 1000;
          
              printf ("TEST: Start child %d.\n", id);
          
              int i;
              for (i = 0; i < nb_loops; i++) {
          
                  printf ("TEST: Child %d is working (loop %d/%d)\n", id, i + 1, nb_loops);
          
                  int j;
                  float r = 0;
                  for (j = 0; j < 100 * id; j++) {
                      float x = 0;
                      do
                          x = (float) rand () / ((float)RAND_MAX + 1);
                      while (x == 0);
                      float y = (float) rand () / ((float)RAND_MAX + 1);
                      float z = sqrtf (-2. * logf (x)) * cosf (2 * M_PI * y);
                      r += z * (1 << 31);
                      usleep (1000);
                  }
              }
              
              kill (getpid (), SIGTERM);
          
              return 0;
          }
          
          
          int child_term (void *data)
          {
              int id = *(int *)data;
              printf ("TEST: Child %d is dieing.\n", id);
              return 0;
          }
          
          #define nb_children 2
          #define nb_loops    10
          
          int main (int argc, char *argv[])
          {
              int d[nb_children];
              int i;
              for (i = 0; i < nb_children; i++) {
                  d[i] = i + 1;
                  register_child (i + 1, NULL, NULL, child_process, child_term, (void *)(d + i));
              }
          
              sleep (100);
          
              return 0;
          }

          瀏覽 17
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  av电影天堂在线 AV黄色在线网站 av麻豆成人电影 | 欧美性猛交一区二区三区精品 | 亚洲三级网 | 日韩在线V | 一本色道久久综合无码欧美 |