These are possible output formats for ps h -eo etime How to parse them into seconds? Please assume at least 3 digits for the days part as I don’t know how long it can be. The output will be egreped to one only line so no need for a loop. Answer With awk: Run with : Output: And finally, if
High mem in arm Architecture
High memory (highmem) is used when the size of physical memory approaches or exceeds the maximum size of virtual memory. The traditional split for architectures using this approach is 3:1, 3GiB for userspace and the top 1GiB for kernel space. This means kernel can at most map 1 GiB of physical memory. In mobi…
ALSA: Ways to prevent underrun for speaker
I am playing a single channel audio in non-interleaved mode. I am getting underrun when I am writing audio data into speaker : ALSA lib pcm.c:7339:(snd_pcm_recover) underrun occurred Here is how I write: What are the different ways/parameter configurations to prevent ALSA under run ? (I am using Linux 3.0, AR…
Hide output from expect
Here’s part of an expect script It read password from kwalletcli, and store in variable passwd. So I can connect to the servers with this passwd. However, the output of kwalletcli is pass through expect and show on console. How can I hide that. Answer Try adding to your script. That should turn off the …
Start background processes from a background process
I have a PHP script say test.php in linux Ubuntu, in this PHP script I use shell_exec() to start several background processes. When I execute php test.php, the background processes are started as expected, but when I run php test.php &, those several background processes are not started. Is it not a suppo…
Is it possible that Accept return a same socket value for different tcp connections on the same machine
Is there possible that accept() (on redhat Enterprise 4/linux kernel 2.6) return a same socket value for different tcp connections from the same process of a same application and same machine? I am so surprised that when I got such a result that many connections have the same socket value on server side when …
How to remove setgid (linux/unix)?
I just changed my file permissions using $ sudo chmod g+s filename and my file permissions turned from drwxr-xr-x to drwxr-sr-x. How do I remove it? Answer Change the + for adding a permission into a – to remove it: If you want to do this programatically, you’ll need to use some bitwise operators. Norma…
Delete a Linux signal handler in C
I use: To add handler of SIGINT event. But how can i delete this handler? Answer Here is what you do: That resets the signal handler back to whatever the default behavior was for that signal (including the default disposition if it hasn’t been set). In the case of SIGINT, it’s aborting your proces…
Bash Shell Script – Check for a flag and grab its value
I am trying to make a shell script which is designed to be run like this: Firstly, in my script I want to check to see if the script has been run with the -t flag. For example if it has been run without the flag like this I want it to error: Secondly, assuming there is a -t flag,
How can I create a basic NASM Assembly (Linux) calculator to add two integers?
I had a go at it, and tried: Sorry about all the XOR instructions, I just wanted to make sure registers were cleared before I used them for a system call, I’m still learning assembly and not sure about what instructions will render a register empty. When I compile, link and run this I can enter the two …