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…
Tag: linux
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 …
How to send mail using Java in a Linux environment?
I have successfully sent mail using Java using apache james server in Windows. I have been trying to do the same in Linux, but couldn’t start the james server. I am a novice in Linux. Is james server really necessary for sending mails? If so how to start james server in Linux? Answer For sending emails …
Substitute a regex pattern using awk
I am trying to write a regex expression to replace one or more ‘+’ symbols present in a file with a space. I tried the following: Expected: Any ideas why this did not work? Answer Use gsub which does global substitution: sub function replaces only 1st match, to replace all matches use gsub.