Fix getrlimit call in main
This commit is contained in:
		
							parent
							
								
									16e428b36f
								
							
						
					
					
						commit
						d1e322d12d
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		
							
								
								
									
										10
									
								
								timeoutd.c
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								timeoutd.c
									
										
									
									
									
								
							|  | @ -38,6 +38,7 @@ | ||||||
| #include    <grp.h> | #include    <grp.h> | ||||||
| #include    <sys/syslog.h> | #include    <sys/syslog.h> | ||||||
| #include    <time.h> | #include    <time.h> | ||||||
|  | #include    <sys/resource.h> | ||||||
| #include    <ctype.h> | #include    <ctype.h> | ||||||
| #include    <termios.h> | #include    <termios.h> | ||||||
| #include    <fcntl.h> | #include    <fcntl.h> | ||||||
|  | @ -351,7 +352,14 @@ char *argv[]; | ||||||
|     if (pid > 0) |     if (pid > 0) | ||||||
|         exit(0); |         exit(0); | ||||||
| 
 | 
 | ||||||
|     for (int i = getrlimit(RLIMIT_NOFILE); i >= 0; --i) { |     struct rlimit r; | ||||||
|  |     if (getrlimit(RLIMIT_NOFILE, &r) == -1) { | ||||||
|  |         openlog("timeoutd", OPENLOG_FLAGS, LOG_DAEMON); | ||||||
|  |         syslog(LOG_ERR, "Coudln't get file resource limit."); | ||||||
|  |         closelog(); | ||||||
|  |         exit(1); | ||||||
|  |     } | ||||||
|  |     for (int i = r.rlim_cur; i >= 0; --i) { | ||||||
|         close(i); |         close(i); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Petar Kapris
						Petar Kapris