Проверка жив ли процесс в UNIXе

    Date: 01/11/06 (Code WTF)    Keywords: no keywords

    Писано каким-то китайцем в далеком 1992 году.

        sprintf(buf, "ps -aux | grep  %s > ps.tab", tran_path);
        system(buf);
    
        input_stream = fopen("ps.tab", "r");
    
        while ((fgets(line, n, input_stream)) != NULL) {
            len = strlen(line);
            line[len - 1] = '\0';
    
            if (os_strstr(line, master_path) != NULL) {
                /* found a line with master */
                fclose(input_stream);
                system("rm -f ps.tab>>/dev/null");
                return (1);
            }
        }
    
        fclose(input_stream);
        system("rm -f ps.tab>>/dev/null");
        return (0);
    

    Source: http://www.livejournal.com/community/code_wtf/23192.html

« Тяжело с PHP на... || MS VBScript в сети... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home