linux

Problem with Pointers

Hi I am new to linux c programming and i have a simple program just for learning and when i compile it it gives me error "dereferencing pointer to incomplete type" here is my code struct Node { struct Node* left; struct Node* middle; struct Node* right; int nodeData; int nodeLevel; char isVisted; }; struct List...

Low latency trading systems using C++ in Windows?

It seems that all the major investment banks use C++ in Unix (Linux, Solaris) for their low latency/high frequency server applications. Why is Windows generally not used as a platform for this? Are there technical reasons why Windows can't compete? ...

C++: can an int be assigned a char* ??

I am reading chapter 2 of Advanced Linux Programming: http://www.advancedlinuxprogramming.com/alp-folder/alp-ch02-writing-good-gnu-linux-software.pdf In the section 2.1.3 Using getopt_long, there is an example program that goes a bit like this: int main (int argc, char* argv[]) { int next_option; // ... do { next_option = g...

C++: How to escape user input for safe system calls?

On a Linux platform, I have C++ code that goes like this: // ... std::string myDir; myDir = argv[1]; // myDir is initialized using user input from the command line. std::string command; command = "mkdir " + myDir; if (system(command.c_str()) != 0) { return 1; } // continue.... Is passing user input to a system() call safe at all? ...

Why do I not see MSG_EOR for SOCK_SEQPAKCET on linux?

Hi, I have two processes which are communicating over a pair of sockets created with socketpair() and SOCK_SEQPACKET. Like this: int ipc_sockets[2]; socketpair(PF_LOCAL, SOCK_SEQPACKET, 0, ipc_sockets); As I understand it, I should see MSG_EOR in the msg_flags member of "struct msghdr" when receiving a SOCK_SEQPACKET record. I am set...

Getting a audio feed from my dailup modem

My linux powered laptop still has a dail-up modem. Is it possible to interface with the phone line through my modem. Using bash or ruby, ( or something else, if I really have to) I would like to record and maybe even and make and receive calls. Can this be done? and if so where do I start? ...

Detect if gdb is running

Hello! I'd like to detect from an application wether gdb is running. The standard way would be the following: if (ptrace(PTRACE_TRACEME, 0, NULL, 0) == -1) printf("traced!\n"); In this case ptrace returns an error if the current process is traced (i.e. running it with gdb or attaching to it). But there is a serious problem with th...

What's the graceful way of handling out of memory situations in C/C++?

I'm writing an caching app that consumes large amounts of memory. Hopefully, I'll manage my memory well enough, but I'm just thinking about what to do if I do run out of memory. If a call to allocate even a simple object fails, is it likely that even a syslog call will also fail? EDIT: Ok perhaps I should clarify the question. If ma...

Shell script to rename files

I wrote a small shell script based on an example I found here: https://bbs.archlinux.org/viewtopic.php?id=36305 it takes this: bash-3.2$ ls test 001 test 002 test 003 test 004 and turns it into: bash-3.2$ ls 001 002 003 004 rename.sh However it gives me this error (even though it works): bash-3.2$ ./rename.sh mv: missing d...

Where is ptrdiff_t defined in C?

Where is ptrdiff_t defined in C? If non-trivial, how can I make this type visible from GCC on Linux? ...

How to limit connection in Linux socket programming?

I want to set the maximum of connection. If it more than the maximum, tell the client now server is full and close the socket. How to write code in C ? Thank you. ...

Is there a command to write random garbage bytes into a file?

I am now doing some tests of my application again corrupted files. But I found it is hard to find test files. So I'm wondering whether there are some existing tools, which can write random/garbage bytes into a file of some format. Basically, I need this tool to: It writes random garbage bytes into the file. It does not need to know t...

MODx requires the pdo_mysql driver when native PDO is being used and it does not appear to be loaded.

Hi all I am fairly new to WHM and Linux, my problem is that I am trying to install Modx on my server. I was initially getting the below error Blockquote MODx requires the pdo_mysql driver when native PDO is being used and it does not appear to be loaded MODx requires the pdo driver when native PDO is being used and it does not a...

Migrating and upgrading Oracle form Solaris to Linux, including stored procedures

Hello, We are planning a migration of an Oracle installation from Solaris to Linux. At the same time we will upgrade to latest version of Oracle. There are a few hundred stored procedures that should be migrated as well. Present version is Oracle SE 9.2. We will still use Oracle SE, potentially with RAC. Is there anything that we mu...

How to set default process scheduling priority ('nice' value) for all remotely logged users?

My desktop allows remote access. I work locally, sometimes other people log in, using ssh/telnet/ftp/rsh. Their processes get the same priority as my own. I would like to set priority ('nice' value) of all processes for people logged in remotely to some higher value, e.g. 10. How can I do that? I tried using pam_group to dynamically as...

Changing static array

Hi, I have a static variable declared in a file: static char *msgToUser[] = { "MSG1 ", "MSG2 ", }; Inside one of the methods of a class I'm doing this: void InfoUser::ModifyMsg( BYTE msgIdx, char *msgString ){ strncpy( msgToUser[ idx ], msgString, DISPLAY_SIZE ); } When I do the strncopy ...

Launching an independent process from php (via httpd)

Hi, i'm trying to spawn a daemon-like process from php on a unix environment, keep the pid for reference and keep it completely independent from httpd processes. This is useful for controlling middleware applications from administrative backoffices. I want to keep it generalized to reuse for any command, i don't want to write a .sh for ...

constraints when dynamically loading a shared object from another shared object?

I'm dynamically loading (whith dlopen()) a shared object (named libprofile1.so) from main. In libprofile1.so I have defined factory function CreateProfile and class Profile. CreateProfile function creates an instance of Profile class and returns a pointer to it. Class Profile has a method pMethod. In main, after loading libprofile...

Matlab - run file without opening GUI, then quit

I want Matlab to run some .m file, which writes to a text file. I don't want the GUI to launch, and I don't want the command line interpreter to run. I've got matlab -nodisplay -r myfile But this still runs the interpreter. What options should I be using? ...

What is the meaning of error code 24 on Linux?

I'm running a Java program through a Python script on Linux, but the program crashes without outputting any error messages. The os.system command that executes the Java program outputs an error code of 24. What does this mean? ...