file-descriptor

Update failed of file descriptor limit

这一生的挚爱 提交于 2019-12-25 02:53:47
问题 I have a server with Debian wheezy x64, I have problem with asterisk server "Try increasing max file descriptors with ulimit -n", I try to change the file descriptor limit as follows: # su - asterisk $ ulimit -Hn 4096 $ ulimit -Sn 1024 $ exit # vi /etc/security/limits.conf I added in the end of the file: .... asterisk soft nofile 65535 asterisk hard nofile 65535 # End of file And when I try to test: # su - asterisk $ ulimit -Hn 4096 $ ulimit -Sn 1024 $ am I miss somethings? (I rebooted the

Resource leak in Android

空扰寡人 提交于 2019-12-25 01:46:20
问题 I have been developing an android app for a few weeks now and keep seeing this problem every now and again: 06-24 14:04:48.915 1530-1539/android.process.acore E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. java.lang.Throwable: Explicit termination method 'close' not called at dalvik.system.CloseGuard.open(CloseGuard.java:184) at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java

C: stdin and std* errs

帅比萌擦擦* 提交于 2019-12-25 00:37:27
问题 I want to manipulate Stdin and then Std* . But I am getting the following errors, $ gcc testFd.c testFd.c:9: error: initializer element is not constant testFd.c:9: warning: data definition has no type or storage class testFd.c:10: error: redefinition of `fd' testFd.c:9: error: `fd' previously defined here testFd.c:10: error: `mode' undeclared here (not in a function) testFd.c:10: error: initializer element is not constant testFd.c:10: warning: data definition has no type or storage class

Overwrite a properties file from the FileOutputStream obtained through FileDescriptor FD

蓝咒 提交于 2019-12-24 19:10:13
问题 Peculiar problem is When I am using the properties.store code with the FileOutputStream obtained from file path, the above method works all fine but when I do that from FileOutputStream obtained from FileDescriptor the properties file append to it, doesn't overwrite. Now my constraint is to use the later approach since I am using FileLock and cant get the FileOutputStream through file again. Is it possible? To do something with the later approach and overwrite and If not what are my options?

Duplicate file descriptor after popen

无人久伴 提交于 2019-12-24 15:32:36
问题 I am using popen to execute a command under linux, then 4 process wile use the same output. I am trying to duplicate the file descriptor again to pass it to each process. here is my code: FILE* file_source = (FILE*) popen(source_command, "r"); int fd = fileno(file_source); fdatasync(fd); int dest_fd[4], y, total = 4; for (y = 0; y < total; y++) { dest_fd[y] = dup(fd); } actually if total set to 1 it work fin, after changing total = 4 it does not work anymore. this answer is too close to what

Allocating a lot of file descriptors

六月ゝ 毕业季﹏ 提交于 2019-12-24 13:20:00
问题 I am interested in bringing a system down (for, say 15 minutes) by allocating a lot of file descriptors and causing Out-of-File-Descriptor failure. (Don't worry, I am not trying to hack into anything. This is for testing a service I am writing... to see how it behaves under other programs misbehaving.) Any best practices for that? Should I just keep saying fopen() in a infinite for loop? And after 15 minutes, I can kill the process? Does anybody have experience with this? Update: I am running

How do I redirect stdout from one process to be read as file descriptor 3 in another?

99封情书 提交于 2019-12-24 13:06:59
问题 I want to redirect (stdout,stderr) from one process to (stdin,file descriptor 3) of another. How do I do that? For example, if I have myscript.sh : #!/bin/sh # myscript.sh echo "stdout" echo "stderr" >&2 And reader.sh : #!/bin/sh # reader.sh read key echo "stdin: $key" read key <&3 echo "fd3: $key" How do I pipe the output of myscript.sh to reader.sh such that the final output is: stdin: stdout fd3: stderr The closest I've gotten is: ./myscript.sh 2>&3 | ./reader.sh But that hangs waiting for

How do I obtain the output from a program that uses screen redrawing for use in a terminal screen scraper?

笑着哭i 提交于 2019-12-24 03:23:46
问题 I am trying to obtain the output of a full-screen terminal program that uses redrawing escape codes to present data, and which requires a tty (or pty ) to run. The basic procedure a human would follow is: Start the program in a terminal. The program uses redrawing to display and update various fields of data. The human waits until the display is consistent (possibly using cues such as "it's not flickering" or "it's been 0.5s since the last update"). The human looks at the fields in certain

Pipe: Bad file descriptors

南楼画角 提交于 2019-12-24 00:44:02
问题 I know this kind of posts have been asked previously, but their level are clearly higher than mind, I still don't get it after reading their post, so I decide to post this question again from here. I am learning multi-processes communication using pipe, I have confronted to this error called Bad file descriptors, I don't understand why I am having this error in my code. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <string.h> #define SIZE 50 struct

Invalidate Stream without Closing

巧了我就是萌 提交于 2019-12-24 00:03:27
问题 This is a followup to anonymous file streams reusing descriptors As per my previous question, I can't depend on code like this (happens to work in JDK8, for now): RandomAccessFile r = new RandomAccessFile(...); FileInputStream f_1 = new FileInputStream(r.getFD()); // some io, not shown f_1 = null; f_2 = new FileInputStream(r.getFD()); // some io, not shown f_2 = null; f_3 = new FileInputStream(r.getFD()); // some io, not shown f_3 = null; However, to prevent accidental errors and as a form of