作业控制程序 LibChildControl

码农软件 · 软件分类 · 作业/任务调度 · 2019-09-04 23:43:27

软件介绍

LibChildControl 能创建一个线程来管理子进程,并且在失败的时候重启他们。

使用示例:

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;
}

本文地址:https://www.codercto.com/soft/d/13899.html

Pro Git (Second Edition)

Pro Git (Second Edition)

Scott Chacon、Ben Straub / Apress / 2014-11-9 / USD 59.99

Scott Chacon is a cofounder and the CIO of GitHub and is also the maintainer of the Git homepage ( git-scm.com ) . Scott has presented at dozens of conferences around the world on Git, GitHub and the ......一起来看看 《Pro Git (Second Edition)》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

随机密码生成器
随机密码生成器

多种字符组合密码

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码