file-descriptor

shell script working fine on one server but not on another

房东的猫 提交于 2020-01-05 04:31:10
问题 the following script is working fine on one server but on the other it gives an error #!/bin/bash processLine(){ line="$@" # get the complete first line which is the complete script path name_of_file=$(basename "$line" ".php") # seperate from the path the name of file excluding extension ps aux | grep -v grep | grep -q "$line" || ( nohup php -f "$line" > /var/log/iphorex/$name_of_file.log & ) } FILE="" if [ "$1" == "" ]; then FILE="/var/www/iphorex/live/infi_script.txt" else FILE="$1" # make

Node.js : EBADF, Bad file descriptor

风格不统一 提交于 2020-01-03 07:17:08
问题 If I reload my application (from the browser with the reload button) a lots of times like 50 reload/10 seconds it gives me this error: events.js:45 throw arguments[1]; // Unhandled 'error' event ^ Error: EBADF, Bad file descriptor This seems to me like a bandwidth error or something like that, originally I've got the error when I played with the HTML 5 Audio API, and If I loaded the audio file 10-15 times sequentially then I've got the error, but now I've discovered that I get the error

How to see file handles like with “lsof -l”?

◇◆丶佛笑我妖孽 提交于 2020-01-02 07:08:50
问题 I did the commands (source): $ exec 3>/tmp/thirdfile $ exec 4>/tmp/fourthfile $ echo drib >&3 $ echo drab >&4 $ echo another drib >&3 $ echo another drab >&4 $ exec 3>&- $ exec 4>&- How can I see the file handles, something like with lsof -l ? 回答1: I don't understand, why not just use lsof: lsof -p $$ $$ being a shell variable that holds the shell's process ID You can also limit to just file descriptors like: lsof -a -d0-65535 -p $$ 回答2: On Linux, you can do something like ls -l /proc/$$/fd ,

Creating a shell in C. How would I implement input and output redirection?

大憨熊 提交于 2020-01-01 07:19:25
问题 I'm creating a shell in C, and I need help implementing input and output redirection. When I try to create a file using ">" I get an error message saying the file does not exist. When I try to do something like ls > test.txt; it won't create a new file. I updated the code with the suggestions provided to me, but now I got different errors. However, a new file is still not created for the output redirection. This is my full code: #include <stdio.h> #include <stdlib.h> #include <string.h>

increase ulimit for # of file descriptors

我的梦境 提交于 2019-12-31 00:59:10
问题 As normaluser : $ ulimit -n 4096 -bash: ulimit: open files: cannot modify limit: Operation not permitted As root it works as desired - but then it won't affect normaluser . How to get out of this catch 22? I'll need this to be persistent. 回答1: You may want to look at /etc/security/limits.conf 回答2: To change file descriptor limit as normal user before running any applicaiton. I use this small utility fdlimit which will increase file descriptor limit using "setrlimit()" system call before

C get all open file descriptors

六眼飞鱼酱① 提交于 2019-12-30 09:32:36
问题 I want to implement behavior in my C program so that if a SIGINT happens, I close all open file descriptors. Is there a simple way to get a list of them? 回答1: I'd use brute force: for (i = 0; i < fd_max; ++i) close (i); . Quick and pretty portable. 回答2: Keep track of all of your open file descriptors and close them individually. In the general case, a library you're using might have an open file, and closing it will cause that library to misbehave. In fact, the same problem could exist in

C get all open file descriptors

Deadly 提交于 2019-12-30 09:32:12
问题 I want to implement behavior in my C program so that if a SIGINT happens, I close all open file descriptors. Is there a simple way to get a list of them? 回答1: I'd use brute force: for (i = 0; i < fd_max; ++i) close (i); . Quick and pretty portable. 回答2: Keep track of all of your open file descriptors and close them individually. In the general case, a library you're using might have an open file, and closing it will cause that library to misbehave. In fact, the same problem could exist in

C: how to redirect stderr from System-command to stdout or file?

可紊 提交于 2019-12-30 06:24:18
问题 The shell command $ avrdude -c usbtiny outputs text to stderr. I cannot read it with commmands such as head-less-more cos it is not stdout. I want the text to stdout or to a file. How can I do it in C? I have tried to solve the problem by my last question but still unsolved. 回答1: I've not tried something like this in OpenBSD, but in at least a few *nix-like systems, you can do this using dup2 . #include <unistd.h> #include <stdio.h> int main(void) { fprintf(stderr, "This goes to stderr\n");

bash redirecting stdin to script

99封情书 提交于 2019-12-25 06:58:13
问题 I went through some bash i/o tutorials but most of them concern redirecting stream to/from files. My problem is the following: how to redirect stdin/stdout/stderr to script (or program). For instance I have script "parentScript.sh". In that script I want to call blackbox "childScript.sh" which takes few arguments -arg1 -arg2 ... and reads input from stdin. My goal is to feed childScript.sh with some input inside parentScript.sh: ... childScript.sh -arg1 -arg2 ????? < "input1" ????? < "input2"

Equivalent of fgetc with Unix file descriptors

心已入冬 提交于 2019-12-25 04:43:37
问题 The fgetc(3) function takes a FILE * as its input stream. Must I reimplement character-at-a-time input with read(2) , or is there a <unistd.h> -style equivalent taking an integer file descriptor instead? 回答1: No, there isn't such a thing, and please never do read(fd, &ch, sizeof(char)) (explanations below). The function read(2) is usually implemented as a system call to the operating system kernel. Although the internal (and funky) details of such a thing shall not be discused here, the