linux

Preventing threads from writing to the same file

I'm implementing an FTP-like protocol in Linux kernel 2.4 (homework), and I was under the impression that if a file is open for writing any subsequent attempt to open it by another thread should fail, until I actually tried it and discovered it goes through. How do I prevent this from happening? PS: I'm using open() to open the file....

Good OpenGL tutorial for Linux/Ubuntu?

I'm looking for a good Ubuntu OpenGL tutorial for a friend who already knows how to use OpenGL in Windows. Can anyone recommend any? ...

How to set C++ environment variable in Linux ubuntu?

I just installed Ubuntu on my Virtualbox on Windows. I was trying to install cmake and the installation guide in the cmake website asked me to do the following steps ./bootstrap make make install But when I just did the ./bootstrap command I get the following list of errors, can anyone suggest me how I can set the C++ compiler on my...

How do I use python to hit this command and return the result?

$whois abc.com I want to use python to hit this command, and then give the result as a String of text. How can I do that? ...

How to take user input during install

So when I create a debian package, I am able to write a post-installation shell script that runs just fine. Currently mine is configured to do echo "Please enter your MySQL Database user (default root)" read MYSQL_USER echo "Please enter the MySQL Database user password (default root)" read -s MYSQL_PASS DBEXIST=0 CMD="cre...

telnet client connection stops receiveing data, server is still sending

I'm Working in an embedded linux environment. it launches a telnet daemon on startup which watches on a particular port and launches a program when a connection is received. i.e. telnetd -l /usr/local/bin/PROGA -p 1234 PROGA - will output some data at irregular intervals. When it is not outputting data, every X period of time it se...

How to get Command history by cursor key in Linux tclsh : TCL

I am new to TCL and I wanted to know, if I can get the command history by using cursor key (like up arrow key) in TCL shell (tclsh). I am running tclsh on fedora with linux version 2.6.21. ...

How to use a defined struct from another source file?

Hi, I am using Linux as my programming platform and C language as my programming language. My problem is, I define a structure in my main source file( main.c): struct test_st { int state; int status; }; So I want this structure to use in my other source file(e.g. othersrc.). Is it possible to use this structure in another sour...

Is it possible to run php exec through cygwin?

Hey guys I have one php exec command that works on my remote linux server but not my windows (WAMP package) local server. I really want to create an identical workstation so I can test locally and then update my remote server. If anyone has any suggestions or solutions other than converting to linux, I would really appreciate it. <?php ...

LBA48 in Linux SCSI ATA Passthrough

I am writing a custom disk monitoring/diagnostics app which, among other things, needs to do stuff to SATA disks behind a SAS PCI card under Linux. So far I am following this guide as well as the example code in sg_utils to pass ATA taskfiles through the SCSI layer. Seems to be working okay. However, in both cases, the CDB data structur...

problem with fork()

I'm writing a shell which forks, with the parent reading the input and the child process parsing and executing it with execvp. pseudocode of main method: do{ pid = fork(); print pid; if (p<0) { error; exit; } if (p>0) { wait for child to finish; read input; } else { call function to parse input; exit; } }while condition return; ...

Solved: Help with this compile error

I just picked up an old project and I'm not sure what the following error could mean. g++ -o BufferedReader.o -c -g -Wall -std=c++0x -I/usr/include/xmms2 -Ijsoncpp/include/json/ -fopenmp -I/usr/include/ImageMagick -I/usr/include/xmms2 -I/usr/include/libvisual-0.4 -D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -DQT_CORE_LIB -DQT_GUI_LIB...

How to get the linux folder and file icons and names in java?

I'm creating a tree of folders and files in java. Windows and OSX return the system icons and name with the following code: new JFileChooser().getIcon(File f); new JFileChooser().getName(File f); Is there any possibility to get the icons and name of unix systems?. A system command would be ok too. Thanks. ...

Kernel panic - Creating own AMI (Amazon Machine Image)

I have created own AMI and registered it on Amazon EC2. But while AMI startup I receive following error: Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(8,1) The image is running locally without any problems. fstab contains: proc /proc proc defaults 0 0 /dev/sda1 /...

Is it possible to trim a log file a daemon has open without the daemon closing the file?

I have a daemon writing to a log file that, eventually, fills up the disk. Is there a way for me to periodically limit the size of the log file without stopping the daemon without changing the code in it? SIGHUP kills the daemon. ...

Path managment in Linux programs

I have a newbie Linux programming question. Suppose I have a project that uses Autotools for compiling and deployment, and I have data files that are to be installed in a location like /var/something or /usr/share/something etc., but in Autoconf, I can change these installation paths. How should the program find these files? How does it ...

Populate The Custom Yum Repository with list

I have a list of 350 rpms listed in a text file that are also installed in a cluster that is not online with the outside world. We have an internal yum repository. Is there a way to take the list, and download all the 350 installs for yum to bring back to the cluster? I hate thinking of downloading them one by one. Thanks ...

How to hook a function for a particular shared ELF library?

LD_PRELOAD hooks some functions for the entire process, but I need to hook a particular function for only one dynamically linked library by its name. ...

Convert a GTK python script to C

The following script will take a screenshot on a Gnome desktop. import gtk.gdk w = gtk.gdk.get_default_root_window() sz = w.get_size() pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False, 8, sz[0], sz[1]) pb = pb.get_from_drawable(w, w.get_colormap(), 0, 0, 0, 0, sz[0], sz[1]) if (pb != None): pb.save("screenshot.png", "png") prin...

How to set file permission for linux host under windows ?

For example, i want a file has permission of 644 automatically when i uploaded it to my linux host, before upload, it is under windows. How could i do this? Btw, i use Filezilla for upload Updated: Before post this question, actually, i ever thought it is impossible too. But, as i has many wordpress sites, i remembered that i never nee...