From b2342ecade45f80b9877ac6cbbf99b10a1e83b9c Mon Sep 17 00:00:00 2001 From: Sergiusz Warga Date: Sat, 3 Apr 2021 20:08:15 +0200 Subject: [PATCH] Added Topic 6 --- Topic-6/task_6_1 | Bin 0 -> 17000 bytes Topic-6/task_6_1.c | 32 ++++++++++++++++++++++++++++++++ Topic-6/task_6_2 | Bin 0 -> 16864 bytes Topic-6/task_6_2.c | 17 +++++++++++++++++ Topic-6/task_6_3 | Bin 0 -> 17224 bytes Topic-6/task_6_3.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ Topic-6/task_6_4 | Bin 0 -> 17224 bytes Topic-6/task_6_4.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 137 insertions(+) create mode 100755 Topic-6/task_6_1 create mode 100644 Topic-6/task_6_1.c create mode 100755 Topic-6/task_6_2 create mode 100644 Topic-6/task_6_2.c create mode 100755 Topic-6/task_6_3 create mode 100644 Topic-6/task_6_3.c create mode 100755 Topic-6/task_6_4 create mode 100644 Topic-6/task_6_4.c diff --git a/Topic-6/task_6_1 b/Topic-6/task_6_1 new file mode 100755 index 0000000000000000000000000000000000000000..3161e1955e06ee0c2b4502adf27a6ac696284612 GIT binary patch literal 17000 zcmeHOeQX@X6`#Aa691spJ;kZnrZK4L%ke!>hlRi@{1JiBi^yGh2-Y&9hP^25-rd=j1m~wfa z13Qe%znl0m@22t=dk(`Cf2I^(QJ+coHaFF0l69GMwm4ij+|pdv+!QY4!W(22uwGaO z_Nnc+_6Tq@g&2iVK8qUSrM%)U{}WC3u6wqn|GnccHV(gc`ik4x2bPICn9!cP1oD_) z4j1Z}?Y|FlCWiD(>KB7Z7fU(_lrqA#fL&1r|I{KlK96$x6M!plxzn`(l+(X_5&SX0 z6}a39V_eS9Rg2)CSOmw{2;00M!E;XFV{I0x;j|97R3anpjze}RmCxt$VyLJWL|-ny zUuarEk0!F3{(?QkZ{5ut_7^`~ z^TSg!+vs z-EW*$$9`OOQdZH}^hJQ@jCK2gR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t pid; + int status; + + pid = fork(); + + if (pid == -1) { // If something went wrong. + perror("Fork: "); + exit(EXIT_FAILURE); + } + + if (pid == 0) { // If this is a child process. + child_task(); + exit(EXIT_SUCCESS); + } + + wait(&status); + return 0; +} diff --git a/Topic-6/task_6_2 b/Topic-6/task_6_2 new file mode 100755 index 0000000000000000000000000000000000000000..ddeb2b8a1c8460503f8a29f5e752a48152374dbe GIT binary patch literal 16864 zcmeHOeQXrR6`%8AY`)GWKrqn4h7#2f`7mG{pmMo0KC`ZDpkOCNg)C>^oqgp#oV&eZ z(<*UGf^srWE%lG`2dYRvRMbW-k*bQKwlUC>pe6_+R1rmO-KeN`MX7NiavI?J-t2ql z-SxSsRsU*tq`Tj|-@Nx`_RZ|v&h5+#f#${{mrHPRi_Z#_hRY4cM+M3j$^iJpCNU4b zSBT|eCde}+XO#O4fKnq}FS24O@oqr0tH4YF{DeUZMs6V@+D(@xutAU*1ziW)6=MO( zb}XiLFmidmJ_U^-De^my-KYSG(QJoJIbJ1;#ql~T_E22<2-yxrv^zz1r^t?RjOt_L zcw$WOvx%<5jtZ1vQslP~cDub~XU7K8XT&-%?YW_c{*(H4k=-gqx)FBddKkIB&x0Lx ztzr0(Z|>&ZRNr*{&_(fQr0|Nhv1og3&DvO~Di%#-da8Oh)mGKkc+*MmdRa5J3+uo! zwS7mM05?O(Q5a=kEF>Ar)7Q@LiNE;nPrrNT;{|8+9p74Y^NX*r53Cb)FrhsU36wEE z8$PIGT>n=gXK;vD!ubRLe1oy299MrWbjGiVNp z=M}!6hvpmnNt!p9?<2m{XOuI~^7X9-k7Eq$=QM2MajbJ1G4ba6a?Hd-L-T3E#N&A8 zbei}QAk5?bjEU!a3T=i=JkJftzh&al7pE&Gp0An99CRY!M8JuF69FdzP6V6?{69wE z?`6yXp&q$es`eMZw^j)Cr6Ij2cSSw&tI`WH9J!5$fgaC2{$+r&6$16Uuw;DnkGWiK zP|EngI6itcFXMyU_~^O3j1O?*qp#;>d~h2deU)YK9+%!5g!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kmF=7AkBWNT-`xB?V|4-QL6|!SIK<*f9?#1_Q_I;$l$okXSpSIca`hjs58xpcV z#-G{jhpB*Z5qFHup54A-v*+~)BmZx~`u6z!n(Xt{D5Ocal0*i({X0;A{m1sJ6ho7- z!4UJ`cKi3C#B9&&AV$9b*a43pmTy1?*Az7E +#include + +int main() { + char msg_write[] = "write() to dup(1)\n"; + int soutfd = dup(STDOUT_FILENO); + write(soutfd, msg_write, sizeof(msg_write)); + + FILE *fakeout = fdopen(soutfd, "w"); + fprintf(fakeout, "using fprintf() on fakeout\n"); + + return 0; +} \ No newline at end of file diff --git a/Topic-6/task_6_3 b/Topic-6/task_6_3 new file mode 100755 index 0000000000000000000000000000000000000000..ca80d4f033daa58aa43f07f66dd00a6b280fbbf6 GIT binary patch literal 17224 zcmeHOZ*UvM6<=F%;y|J}Gy#(UIVfQgs1@g*aYEflw&k2VP6&xz(n7c>mTarBBqN;~ zo1tKEV4_J(&4&*8KxdrkFr`yEgrU;`rWB_s5QajN5ADza+LR%!MJaUzbkdgO`g?c# z&Ua_2w6tG3qxDF?eZPJ0?e4q1)va&$-f%}-WkrSHKBuy-|n4l~;aFfgcf}&B( z$M-UEm6#2AmdRP=K?_i7r8g?wSS@)UknCzHQv|QDXu-%WBqY01X+l=OC~7QCva6!3 zl)d2I2!TF%V0qQ)w}f)ia_emEJ2fEu%-e_iEjJd$pcO zyk88Y<4L_oq+^k&h-L@Yh>RYEk?7f%j_Wbe-Jiy2mhSh{mdOMfaE>x}H_Cm+3uR8soTEY+fl zW>+gQ#w#6vG{)(Vk#aQNEAg40t{27Q^XcxmUvk+c@wsGih?J3de&slh%Zt<}=TGK$ zOTId2n%VOp%WrJ5c)Hi9eom(yJSw)+q=Uc6W`&q?@O}q>&cVx{ShJMJ0nI1Q@ii#* z=YY2&V>ugk@I2>G$pHsX^9!dj2TyfyI_%(`^Xs^Sr@A>k?%+A5RCd(C)4j&&83#X) zN#KNo$Az`i2?xKxW`#KE;CXI$6qmE*2$UmG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SlF_6w!aRg#O#$ zi=Ol7PU{&xi=8jsV)|HxrYAHU(@4fLI8+f$X}$faJ&}Gbs;AN!Es`A+-KoSte@u@> z1C8|!^~IIwa7SE=q|=ch4gb$i4~d?1BoWi1*+gOpCJsr1rtVVJBbmKggSHmU(zLei zp)Fx8ytP%ssSdYpRA{YV-5T1`-r_DX50Zewc_uBaN)Kx5cA;(VxVbshq21ipwjGh zjd4?S=Elv?xf(Y!7dZ{ zfxIV^k#5W*I@VDjcV%>1$jw;Ce%zd<;p7fqQ99C7^qdYII`Y~%PYt=t=rEF-vCbX2 zIT6SVCG^N1pq{p{k8?P-6iW|?Kr*Gr0=>y>U?81BAN3&zwI_?$PId99q(aT@b$X;% znCg9zOrHouhmxqmLOpGjd?S|5#8XL^prI@s>yMCu%nkJGB4EZkfNY>Q1(7nDShoo1 zu|bG*Q$agrj<`UqPu@m-QFvp?@?qUimIdcgRU{FIGs_&;Qv`4?CvbljnM^(dMNdAM za`BsLrCRyC%*g9PS#0WZp78Vd&{~Y`8>Ky?f-+~~bsBRG$T;nHN_$3nU*}BxyTV*M zGERGb-e*);QKHxWR`7qtT8`V#>s`hb(oQb>?Da9bjUYp7UAE`-gN+niBx)mNx&OQ_ zjf0~uvpugf7&X750yZ1S?7OKG}P(|Dzsz zMcOf*lsivY%=~#2(AeerdELb4 z`1!oPye({hd>wxPTk0a)^Z(O!%LnIilsOaE%SgM~o%SLqwd*b9de{fsu{;mP#Bu#f z&?>1ZVXs)l_BXAcsD7z#^K5^;%~%=IrQ}2&J64JH9h43mW#Fy^je`qz{CNJI3y#}v gSz6zNv_MBX>v7KYTBY=iUfe#u(b8DrG4P1upJG7v^Z)<= literal 0 HcmV?d00001 diff --git a/Topic-6/task_6_3.c b/Topic-6/task_6_3.c new file mode 100644 index 0000000..1458184 --- /dev/null +++ b/Topic-6/task_6_3.c @@ -0,0 +1,44 @@ +// +// Written for Computer Networks and Systems lab classes +// AUTHOR : Sergiusz Warga + +#include +#include +#include +#include +#include + + +int main() { + int pipefd[2]; + if (pipe(pipefd) < 0) { + fprintf(stderr, "Something went wrong!\n"); + return -1; + } + + pid_t pid; + pid = fork(); + + if (pid == -1) { // If something went wrong. + perror("Fork: "); + exit(EXIT_FAILURE); + } + + if (pid == 0) { // If this is a child process. + dup2(pipefd[1], STDOUT_FILENO); + printf("printf() from a child\n"); + close(pipefd[1]); + exit(EXIT_SUCCESS); + } + + char buff[100] = {}; + + while (read(pipefd[0], &buff, sizeof(buff)) > 0) { + printf("PARENT: %s", buff); + } + + int status; + wait(&status); + + return 0; +} \ No newline at end of file diff --git a/Topic-6/task_6_4 b/Topic-6/task_6_4 new file mode 100755 index 0000000000000000000000000000000000000000..538f6d2f73ca317f0d570d936a657d4c6f41577e GIT binary patch literal 17224 zcmeHOeQX@X6(9TJ#DwJRqzO1lAxj|C1blHmaYEDFIkvN|oDh;2s7hF$eP{c~eK>b} zjg1gBHHmT!E~!M-AXSx7RYBGM5!6;nky4z7CTR;Osj4a!Eu^TZc1yt=P^Cb!{k`3J zd%NqqQmX#ZO7~8CZ{F{H%gY>78Ffl zF20wF>%~mSGfd3V2Q3DzMHedFyjtQuaPq68LJ|IH3l_||g~Z9P6phOYn2TD=lKiTu zC}l72G?hXyXT4pYLe3z?{I>ZaG5|4m`cZDW8cen5+T`ZPWM0lm&VD44-+=TRkbcak zWPQvzpOh0inq)q`T!D^AF~5cI`rRx2yu3x)Gp9O;cD^)To9 z?t&lX<=-W~%sXX$rLM!6%s+FPUa>MB>t4ThWjxXlk0rB%4TDYV8`iH4WKx0EW)rAg zR0nmNt=l^V!i*Cp(`a6c1yUyc`HK&p96z0SAo;|Nv!D3ti|XRvFRtYnR43UGkw13{ zlBrC$BH5VdU-1Y^qLQ%rIL=33PHe~@=G%mHE_xD@;zBIpHZbz{QagZRICaBf_X}rIJ~3)DAt~5wbUxvd=+X2iI zi-i)jG<-h_^t&GFX6r?CFs9=x+7lQ1!zd2K2BKmhnog(EqBoV^D>N;mhkN#FJ^g#N z-f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{|Yot|6#>4WnN862XX&l z=nWKT?#5~2`3dj)_S&<|oaQN*UEBUVf9-Do2x2=+D#(mqhJyMo*U$4@-p9}T_2q40 z$K&h&efZKTvOoWy)+HaP$Dnf(*UNk+oSpt6D6JbU&h>B%_G5VtoC)Llm7t}mE#a?N zYWth!RaCz;w{iAgVIx+7Y>Awl`;MitzJoGglT6%ofU$AG&L5Az^gkiD-SV`)2Wf&1 Z%6o!yy_S}q(Tn>(u+g$u>~Zjj;-8dMNz4EM literal 0 HcmV?d00001 diff --git a/Topic-6/task_6_4.c b/Topic-6/task_6_4.c new file mode 100644 index 0000000..f66a970 --- /dev/null +++ b/Topic-6/task_6_4.c @@ -0,0 +1,44 @@ +// +// Written for Computer Networks and Systems lab classes +// AUTHOR : Sergiusz Warga + +#include +#include +#include +#include +#include + + +int main() { + int pipefd[2]; + if (pipe(pipefd) < 0) { + fprintf(stderr, "Something went wrong!\n"); + return -1; + } + + pid_t pid; + pid = fork(); + + if (pid == -1) { // If something went wrong. + perror("Fork: "); + exit(EXIT_FAILURE); + } + + if (pid == 0) { // If this is a child process. + dup2(pipefd[1], STDOUT_FILENO); + execl("/usr/bin/cal", "cal", NULL); + close(pipefd[1]); + exit(EXIT_SUCCESS); + } + + char buff[200] = {}; + + while (read(pipefd[0], &buff, sizeof(buff)) > 0) { + printf("%s", buff); + } + + int status; + wait(&status); + + return 0; +} \ No newline at end of file