From 24324dcadb57a4438aa709ac52e4fe10ce8d35d9 Mon Sep 17 00:00:00 2001 From: asandikci Date: Wed, 26 Jul 2023 15:58:21 +0300 Subject: [PATCH] remove logs --- c-daemon/bin/test | Bin 16008 -> 16008 bytes c-daemon/daemon/daemon.c | 27 ++++----------------------- c-daemon/daemon/test.c | 3 --- 3 files changed, 4 insertions(+), 26 deletions(-) diff --git a/c-daemon/bin/test b/c-daemon/bin/test index 6cb9a3739be5418bb56beefe32fbd8e12202efbe..4978bb49246f5aa14d18784f79600a1719b65bdc 100755 GIT binary patch delta 603 zcmeCE?WoCC{d|0J>ffE}o98e)@(Jz(Dc=twUKoRj`IEJTWb423GB9{_9^U~LH~IJf|Ado= zLp?g5dNjXL=&XIyS^DC|JfLW&>zC%*FASAj`$3L)kqs0A@$0xC21WzrroY#*SKJ&}{ z0{V`_qxlHO;muElrFkY7aNL=sz%p4x!9eN9`~UwlfR^p}@c(}Rkly$a7$iXY0+8MS zq`!ZhoTi|~m@s*wf;eNx5tH6F1>$Dj2e?U4g00!g@B5I;0}ah=mye4O#BQ$ zRhtaW7@2+uPJU(N$0)zq(m0=;QF`)9D}Am%P(6QyCO@)rV^p84X|2zRND+zF=9~!% N5c3i?FSLHn1OUkx;u!z{ delta 830 zcmYk4O=uHQ5Xax!^lM|9G#?;{AFCBi1r1TLweb?#m5ACFTZ_;`@g^b|555wop=jp%;XCo&SW1-@O-3ASG3opHIX(>S{-?};GtjA=_iB3U<|$F%vnHC$eF(b zEuQ;Yjjy*ae!h?CU7f7sYwtHY_R&iypCD=LG=AWWpJIH&) zn6{k{i)rn^UKJ_&Gg#c)bX)0YtW)|u^*HgJkVf!!ici`e{~1stbk+YT(;uAmh^0eq zN-k)+4{s^FO{md(I|c%P@RVWLNxT8Y$3VS|9_PxjfcSo-iw~G5j$W(h>*85^#GMOL h1p^~Kx1Zvzq9qnl|Nr!tVy$XYD-$ef&cwbde*gt>N%sH% diff --git a/c-daemon/daemon/daemon.c b/c-daemon/daemon/daemon.c index ccd49c7..07b4f9f 100644 --- a/c-daemon/daemon/daemon.c +++ b/c-daemon/daemon/daemon.c @@ -17,61 +17,42 @@ int _daemon(int nochdir, int noclose){ // pid_t defined in sys/types.h // pid_t is a signed int data type - logg(1); pid = fork(); // fork of the parent process // fork() function defined in unistd.h - logg(2); - if (pid < 0){ - logg(3); exit(EXIT_FAILURE); // exit and EXIT_FAILURE defined in stdlib.h } else if (pid > 0){ - logg(4); exit(EXIT_SUCCESS); } - logg(5); sid = setsid(); - logg(8); if (sid < 0) { - logg(9); exit(EXIT_FAILURE); } - logg(10); - if ((chdir("/")) < 0) { - logg(17); exit(EXIT_FAILURE); } - logg(11); if (!noclose) { - logg(12); - for (int i = 0; i < NR_OPEN; i++) + for (int i = 0; i < NR_OPEN; i++){ close(i); - logg(13); + // close(STDOUT_FILENO); => close(1); + // close(STDERR_FILENO); => close(2); + } open("/dev/null", O_RDWR); - logg(14); dup(0); - logg(15); dup(0); - logg(16); } - // close(STDOUT_FILENO); - // close(STDERR_FILENO); while (1) { - logg(6); int status = system("./info"); // TODO SECURITY ISSUE // LINK https://stackoverflow.com/questions/5237482/how-do-i-execute-an-external-program-within-c-code-in-linux-with-arguments# - sleep(1); } - logg(7); exit(EXIT_SUCCESS); } \ No newline at end of file diff --git a/c-daemon/daemon/test.c b/c-daemon/daemon/test.c index 07b860c..bfcefa3 100644 --- a/c-daemon/daemon/test.c +++ b/c-daemon/daemon/test.c @@ -3,10 +3,7 @@ int _daemon (int, int); int main(){ - printf("START"); _daemon(0, 0); - printf("END"); getchar(); - printf("CLOSE"); return 0; } \ No newline at end of file