linux

Java socket bug on linux (0xFF sent, -3 received)

While working on a WebSocket server in Java I came across this strange bug. I've reduced it down to two small java files, one is the server, the other is the client. The client simply sends 0x00, the string Hello and then 0xFF (per the WebSocket specification). On my windows machine, the server prints the following: Listening byte: 0...

sendmail working but PHP mail() is failing

I cant seem to send an email using PHP's mail(). I have also tried PHPMailer and Swiftmail with no success. However, the following command on the server delivers mail successfully. cat test.txt | mail -s "test mail" [email protected] Is there a way to trace where the problem is coming from? mail() just seems to return true or false. ...

How do I stop/workaround Java apps stealing focus in Linux window managers

We want to quickly prototype widgets in Java. We overlay them on top of a display written in a proprietary 3rd party graphics package. We find that the Java GUI steals keyboard focus away from the window manager. The window manager is fvwm, I've tried configuring it so the Java app is setup not to get focus, and furthermore if it ever...

Allowed characters in linux environment variable names

What characters are allowed in linux environment variable names? My cursory search of man pages and the web did only produce information about how to work with variables, but not which names are allowed. I have a Java program that requires an defined environment variable containing a dot, like com.example.fancyproperty. With Windows I c...

Lock a mutex multiple times in the same thread

Hi, I'm developing an application on an embedded linux OS (uClinux) and I need to be able to lock the mutex more than once (by the same thread). I have a mutex and a mutexattr defined and initialized as follows: pthread_mutexattr_t waiting_barcode_mutexattr; pthread_mutex_t waiting_barcode_mutex; pthread_mutexattr_init(&waiting_barco...

Is there a way to make linux CLI IO redirection persistent?

I have multiple piped commands, like this: find [options] | grep [options] | xargs grep [options] Each one of them can potentially produce errors (permissions errors, spaces-in-filenames errors, etc) that I am not interested in. So, I want to redirect all errors to /dev/null. I know I can do this with 2>/dev/null, for each command. Ca...

How is pthread_join implemented?

I'm a little new to threading, so you'll have to forgive the naiveté of this question. How is pthread_join implemented and how does it effect thread scheduling? I always pictured pthread_join implemented with a while loop, simply causing the calling thread to yield until the target thread completes. Like this (very approximate pseudoc...

How to profile my C++ application on linux

HI, I would like to profile my c++ application on linux. I would like to find out how much time my application spent on CPU processing vs time spent on block by IO/being idle. I know there is a profile tool call valgrind on linux. But it breaks down time spent on each method, and it does not give me an overall picture of how much time ...

Running commands though PHP/Perl scripts as a priviledged user on Linux.

Background: I am writing a script for a company that will allow users to create FTP accounts through a web interface. In the background, the script must run a bunch of commands: Add the user to the system (useradd) Open and edit various files mail the user via sendmail and a few other things... I'm basically looking for the most sec...

Offset of a given timezone from GMT in linux shell script

Is there a way to get the offset of a given timezone (identifier like EDT or America/New_York) from GMT in linux shell script? ...

Setting up separate ctags db's for C/C++ standard libs, boost, and third party libs

I want to set up separate ctags databases for various libraries in /usr/include/ for use with OmniCppComplete. The idea is to be able to pull in only the libraries needed for a particular project in the target language - C or C++. For example, I'd like to have one database for the standard C libraries, one for system libraries that m...

How to completely wipe rubygems along with rails etc

Ok, so I decided I'd be cool and try to use Rails3 that's in beta. Then, things were getting hard to manage so I got rvm. I installed ruby 1.9.2-head in rvm and things were working, and then a computer restart later rails wouldn't start up. So I figured I'd just try running the system ruby and start rails in it. same error. Then, I unins...

Generating a reasonable ctags database for Boost

I'm running Ubuntu 8.04 and I ran the command: $ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp /usr/include/c++/4.2.4/ to generate a ctags database for the standard C++ library and STL ( libstdc++ ) on my system for use with the OmniCppComplete vim script. This gave me a very reasonable 4MB tags file which...

Fairness: Where can it be better handled?

Hi, I would like to share one of my practical experience with multiprogramming here. Yesterday I had written a multiprogram. Modifications to sharable resources were put under critical sections protected by P(mutex) and V(mutex) and those critical section code were put in a common library. The library will be used by concurrent applica...

Need to have non-blocking named pipes capable of two way communication in c on Linux

Hi, I want to create one server and one client(two separate programs) where in server creates two named pipes(i guess thats the minimum required for bidirectional flow of traffic) and then the client is started,and Client and server should be able to send and recieve data both ways all the time(full duplex types).I think that would req...

Dynamic loading of shared objects using dlopen()

Hi, I'm working on a plain X11 app. By default, my app only requires libX11.so and the standard gcc C and math libs. My app has also support for extensions like Xfixes and Xrender and the ALSA sound system. But this feature shall be made optional, i.e. if Xfixes/Xrender/ALSA is installed on the host system, my app will offer extended fu...

How to know from a bash script if the user abruptly closes ssh session

I have a bash script that acts as the default shell for a user loging in trough ssh. It provides a menu with several options one of wich is sending a file using netcat. The netcat of the embedded linux I'm using lacks the -w option, so if the user closes the ssh connection without ever sending the file, the netcat command waits forever....

Where are my ruby gems?

Hello, Linux newbie question I guess.. How can I find out where gem installs the gems on my Ubuntu 10 system? I want to read gem sourcecode and perhaps change things up a bit. ...

I don't get coredump with all process

Hello, I try to get a coredump, so i use : ulimit -c unlimited I run my program in background, and I kill it : kill -SEGV %1 But i just get : [1]+ Exit 1 ./Test And no coredumps are created. I did the same with other programs and it works, so why that didn't work with all ? Anybody can help me ? Thanks. (GNU...

Creating a new window that stays on top even when in full screen mode (Qt on Linux)

I'm using Qt 4.6.3, and ubuntu linux on an embedded target. I call dlg->setWindowState(Qt::WindowFullScreen); on my windows in my application (so I don't loose any real-estate on the touch screen to task bar and status panel on the top and bottom of the screen. This all works fine and as expected. The issue comes in when I want to pop...