Trivial Changes
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:50:39 +0200
changeset 68 d549894aa6a9
parent 67 abe63a276a36
child 69 b5912e5f899f
Trivial Changes I have made trivial changes to the fts component and renamed the set_limit function to set_proc_limit. It makes it clear that we are dealing with LIMIT_NPROC and not LIMIT_AS settings. committer: Markus Bröker <mbroeker@largo.homelinux.org>
ddos/Makefile
ddos/server.c
ddos/set_limit.c
ddos/set_proc_limit.c
fts.c
--- a/ddos/Makefile
+++ b/ddos/Makefile
@@ -6,7 +6,7 @@
   TARGET += server
 
 SOBJECTS  = server.o
-SOBJECTS += set_limit.o
+SOBJECTS += set_proc_limit.o
 
 COBJECTS  = client.o
 
--- a/ddos/server.c
+++ b/ddos/server.c
@@ -13,7 +13,7 @@
 #include <sys/types.h>
 #include <signal.h>
 
-int set_limit (int);
+int set_proc_limit (int);
 
 int main (int argc, char **argv)
 {
@@ -61,7 +61,7 @@
      */
     signal (SIGCHLD, SIG_IGN);
 
-    if (set_limit (500) != 0) {
+    if (set_proc_limit (200) != 0) {
         printf ("Cannot limit the process limit\n");
         return EXIT_FAILURE;
     }
deleted file mode 100644
--- a/ddos/set_limit.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * test/demos/ddos/set_limit.c
- * Copyright (C) 2008 Markus Broeker
- */
-
-#include <sys/resource.h>
-
-int set_limit (int processes)
-{
-    struct rlimit rlim;
-
-    rlim.rlim_cur = processes;
-    rlim.rlim_max = processes + 24;
-
-    return setrlimit (RLIMIT_NPROC, &rlim);
-}
new file mode 100644
--- /dev/null
+++ b/ddos/set_proc_limit.c
@@ -0,0 +1,16 @@
+/**
+ * test/demos/ddos/set_limit.c
+ * Copyright (C) 2008 Markus Broeker
+ */
+
+#include <sys/resource.h>
+
+int set_proc_limit (int processes)
+{
+    struct rlimit rlim;
+
+    rlim.rlim_cur = processes;
+    rlim.rlim_max = processes + 24;
+
+    return setrlimit (RLIMIT_NPROC, &rlim);
+}
--- a/fts.c
+++ b/fts.c
@@ -9,6 +9,7 @@
 #include <sys/stat.h>
 
 #include <fts.h>
+#include <errno.h>
 
 int compare (const FTSENT ** a, const FTSENT ** b)
 {
@@ -46,7 +47,8 @@
     }
 
     while ((current = fts_read (fts)) != NULL) {
-        printf ("%s/%s\n", current->fts_path, current->fts_name);
+        if (!errno)
+            printf ("%s/%s\n", current->fts_path, current->fts_name);
     }
 
     if (fts_close (fts) < 0)