{"id":768,"date":"2012-03-22T13:17:16","date_gmt":"2012-03-22T12:17:16","guid":{"rendered":"http:\/\/csipet.web.elte.hu\/?p=187"},"modified":"2012-03-22T13:17:16","modified_gmt":"2012-03-22T12:17:16","slug":"6-ora-2","status":"publish","type":"post","link":"https:\/\/peter.csonka.hu\/hu\/blog\/2012\/03\/6-ora-2\/","title":{"rendered":"6. \u00f3ra"},"content":{"rendered":"<p><a href=\"https:\/\/docs.google.com\/document\/d\/1CEpW5HkQDwMgBL196NcCPeC8yQMzGWKO1Obvexx4H_M\/edit\">https:\/\/docs.google.com\/document\/d\/1CEpW5HkQDwMgBL196NcCPeC8yQMzGWKO1Obvexx4H_M\/edit<\/a><\/p>\n<pre lang=\"c\" line=\"1\">\n#include <stdio.h>\n#include <string.h>\n#include <sys\/types.h>\n\n#define MAX_COUNT 200\n#define BUF_SIZE 100\n\nvoid main(void){\n    pid_t pid;\n    int i;\n    char buf[BUF_SIZE];\n    fork();\n    pid = getpid();\n    for(i=1; i <= MAX_COUNT; i++){\n   \t sprintf(buf, \"This line is from pid %D, value = %dn\", pid, i);\n   \t write(1, buf, strlen(buf));\n    }\n}\n<\/pre>\n<p><!--more--><\/p>\n<pre lang=\"c\" line=\"1\">\n#include <stdio.h>\n#include <sys\/types.h>\n#define MAX_COUNT 5\n\nvoid ChildProcess(void);\nvoid ParentProcess(void);\nint x=5; int y=6; int z;\n\nvoid main(void){\n    pid_t pid;\n    pid = fork();\n    if(pid==0){\n   \t ChildProcess();\n    } else {\n   \t ParentProcess();\n    }\n    \n}\n\nvoid ChildProcess(void){\n    int i;\n    for(i=1; i<= MAX_COUNT; i++) printf(\"This line is from child, value = %dn\", i);\n    printf(\" *** child process is done *** n\"); z=x+y;\n}\nvoid ParentProcess(void){\n    int i;\n    for(i=1; i<= MAX_COUNT; i++) printf(\"This line is from parent, value = %dn\", i);\n    printf(\" *** parent process is done *** n\"); printf(\"z erteke: %dn\", z);\n    \n}\n<\/pre>\n<pre lang=\"c\" line=\"1\">\n#include <sys\/types.h> \/\/ forkhoz\n#include <unistd.h>\n#include <string.h>\n#include <wait.h>\n\nint main(){\n    int l;\n    pid_t child=fork();\n    if(child<0){\n   \t perror(\"hiba\");\n    } else {\n   \t if(child>0){\n   \t\t \/\/wait(&i);\n   \t\t while(waitpid(child, &l, WNOHANG)==0){\n   \t\t\t printf(\"Meg varok a gyerekekren\");\n   \t\t\t sleep(1);\n   \t\t }\n   \t\t printf(\"%st pid-szam: %in\", \"szulo \", getpid());\n   \t } else {\n   \t\t sleep(5);\n   \t\t printf(\"%st pid-szam: %in\", \"Gyerek \",getpid());\n   \t };\n    };\n}\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>https:\/\/docs.google.com\/document\/d\/1CEpW5HkQDwMgBL196NcCPeC8yQMzGWKO1Obvexx4H_M\/edit #include #include #include #define MAX_COUNT 200 #define BUF_SIZE 100 void main(void){ pid_t pid; int i; char buf[BUF_SIZE]; fork(); pid = getpid(); for(i=1; i<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"class_list":["post-768","post","type-post","status-publish","format-standard","hentry","category-szamitogepes-alapismeretek-2"],"_links":{"self":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts\/768","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/comments?post=768"}],"version-history":[{"count":0,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/posts\/768\/revisions"}],"wp:attachment":[{"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/media?parent=768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/categories?post=768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/peter.csonka.hu\/hu\/wp-json\/wp\/v2\/tags?post=768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}