Skip to content

Write-only mapping a O_WRONLY opened file supposed to work?

Is mmap() supposed to be able to create a write-only mapping of a O_WRONLY opened file? I am asking because following fails on a Linux 4.0.4 x86-64 system (strace log): The errno equals EACCESS. Replacing the open-flag O_WRONLY with O_RDWR yields a successful mapping. The Linux mmap man page documents the err…

How to run php properly from the command line [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack …

Exec command in Ant only executes first command

I want to list the permission of every script in directory dir/bin. But the below command only runs “ls” in the directory where the script is with below code rather than every script in dir/bin. Since script.xml is there in maindir, it just does a ls inside maindir. There are 2 problems: Performin…

How to stop newline chars from escaping OLD gnu sed command

I am trying to replace a line in a file with multiple lines. When I had only one new line char ( ‘$’n ). it worked fine, however when I use two of them, it escapes my sed and the file wont run anymore. File.txt: DesiredOutput Actual Output Answer Using older BSD sed you can do: This should work wi…

Status after each argument passed to -exec in find

I’m writing a quick script to list all the files in a directory, run a function on each of them, and then print out the status code. Now the status code I would like is of the entire transaction and not the last expression that was executed. For example… Let’s say I have the following files …

Extract desired information from a string in Linux

Below is the string that I get, now I want to extract the two 3840 from this line, what command should I be using in Bash scripting? Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840×3840 [SAR 1:1 DAR 1:1], 100072 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc Answer You can pipe i…

Executing a script from a parent directory?

I have a root directory. In there I have ./bin/ In ./bin/ I have some bash scripts like: These scripts must be ran from ./bin, that is, the working directory must be: however, I would like to do: That last line would set the working directory temporarily to ./bin/ and would execute my script found in ./bin an…

Dynamic library timing and CPU load analysis in linux

I am writing code with one dynamic library. When I used dlopen/dlsym calls to access library functions, cpu load and execution is more as compared to linking library dynamically using -l and accessing function directly. Can anyone help to understand why this is happening? Answer Static linking requires more t…