file-descriptor

Increase max open files for Ubuntu/Upstart (initctl)

南笙酒味 提交于 2019-12-02 20:55:26
This is on an Ubuntu 12.04.3 LTS server. I've added the following to /etc/security/limits.conf (my Golang processes run as root): * hard nofile 50000 * soft nofile 50000 root hard nofile 50000 root soft nofile 50000 I've added the following to /etc/pam.d/common-session session required pam_limits.so I've added the following to /etc/sysctl.conf: fs.file-max = 50000 Yet when I cat /proc/{PID}/limits, I get: Limit Soft Limit Hard Limit Units Max open files 1024 4096 files This happens only when I start the process from Upstart via sudo initctl start service_name . If I start the process myself,

Inter-process communication without FIFOs

本秂侑毒 提交于 2019-12-02 19:39:12
Inside a BASH script we can have multiple processes running in background which intercommunicate using named pipes, FIFOs registered on the filesystem. An example of this could be: #!/bin/bash mkfifo FIFO # BG process 1 while :; do echo x; done & >FIFO # BG process 2 while :; do read; done & <FIFO exit I wonder if it's possible to do the same intercommunication between background processes of a script without using a FIFO on filesystem, maybe with some kind of file-descriptor redirection. Here's an example that runs two subprocesses implemented as functions of the same shell-script... One

Is O_NONBLOCK being set a property of the file descriptor or underlying file?

喜夏-厌秋 提交于 2019-12-02 19:12:13
From what I have been reading on The Open Group website on fcntl , open , read , and write , I get the impression that whether O_NONBLOCK is set on a file descriptor, and hence whether non-blocking I/O is used with the descriptor, should be a property of that file descriptor rather than the underlying file. Being a property of the file descriptor means, for example, that if I duplicate a file descriptor or open another descriptor to the same file, then I can use blocking I/O with one and non-blocking I/O with the other. Experimenting with a FIFO, however, it appears that it is not possible to

socket: Too many open files (24) apache bench lighttpd

孤者浪人 提交于 2019-12-02 15:09:19
When I start Apache Bench test: ab -n 10000 -c 1300 http://domain.com/test.php I get error: socket: Too many open files (24) When i change to '-c 1000' it works fine. Because I can have more than 1000 concurrent users I would like to fix socket too many open files problem or increase parameter. How to do this and where? I use lighttpd on centos 5. ulimit -n 10000 That might not work depending on you system configuration Consult this to configure your system. to permernent change max opened files limit, you should modify /etc/security/limits.conf and reboot system: echo -ne " * soft nofile

How do I make sure that file handle for every `Child` process is released after every iteration?

久未见 提交于 2019-12-02 13:26:29
问题 I have the following program taken from the Rust docs for std::process::Command. It stops working after some iterations. use std::process::Command; use std::process::Stdio; fn main() { loop { let mut echo_child = Command::new("echo") .arg("oh no a tpyo") .stdout(Stdio::piped()) .spawn() .expect("failed to start 'echo'"); let echo_out = echo_child.stdout.expect("failed to open 'echo' stdout"); let sed_child = Command::new("sed") .arg("s/tpyo/typo/") .stdin(Stdio::from(echo_out)) .stdout(Stdio:

Pass File Descriptor - Execve (typecast)

我的梦境 提交于 2019-12-02 10:43:39
I am wondering how I can pass a file descriptor through the execve() command and then access it on the other side. I know that I can use dup2 to redirect the file-descriptor but I cannot do that. I am required to actually pass the file descriptor to the child and use it in the child. What I have done so far: Parent makes pipe + args like the following: int pfd[2]; if(pipe(pfd) == -1) exitWithError("PIPE FAILED", 1); char *args_1[] = {"reader", argv[1], (char*) pfd, (char *) 0}; Then the child calls execve after fork() like the following: close(pfd[1]); execve("./reader", args_1, NULL); Then,

How do I write to a specific raw file descriptor from Rust?

浪子不回头ぞ 提交于 2019-12-02 02:15:37
问题 I need to write to file descriptor 3. I have been searching for it but the documentation is quite poor. The only thing that I have found is the use of libc library and the fdopen method, but I haven't found any example about how to use it or write on it. Can anyone provide me an example of writing to a file descriptor in Rust? 回答1: You can use FromRawFd to create a File from a specific file descriptor, but only on UNIX-like operating systems: use std::{ fs::File, io::{self, Write}, os::unix:

List owner processes of open file handles in Windows?

一个人想着一个人 提交于 2019-12-02 00:55:23
问题 I'm currently getting an "out of handles" error in my Event Viewer for a program. What would be a good program to list what processes are using file handles? An example would be 'lsof' in the *nix world. 回答1: Use processexplorer http://technet.microsoft.com/en-us/sysinternals/bb896653 回答2: You could use Handle tool from SysInternals. https://technet.microsoft.com/en-us/sysinternals/bb896655.aspx 回答3: In this question on Unix SE How to get over “device or resource busy” OP mention that he use

How do I write to a specific raw file descriptor from Rust?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 23:20:32
I need to write to file descriptor 3. I have been searching for it but the documentation is quite poor. The only thing that I have found is the use of libc library and the fdopen method, but I haven't found any example about how to use it or write on it. Can anyone provide me an example of writing to a file descriptor in Rust? You can use FromRawFd to create a File from a specific file descriptor, but only on UNIX-like operating systems: use std::{ fs::File, io::{self, Write}, os::unix::io::FromRawFd, }; fn main() -> io::Result<()> { let mut f = unsafe { File::from_raw_fd(3) }; write!(&mut f,

List owner processes of open file handles in Windows?

依然范特西╮ 提交于 2019-12-01 21:13:22
I'm currently getting an "out of handles" error in my Event Viewer for a program. What would be a good program to list what processes are using file handles? An example would be 'lsof' in the *nix world. Use processexplorer http://technet.microsoft.com/en-us/sysinternals/bb896653 You could use Handle tool from SysInternals. https://technet.microsoft.com/en-us/sysinternals/bb896655.aspx In this question on Unix SE How to get over “device or resource busy” OP mention that he use LockHunter on Windows. It's great tool, just right click on file or directory and find the process that locking it and