unix

Does the OS (POSIX) flush a memory-mapped file if the process is SIGKILLed?

If a process is killed with SIGKILL, will the changes it has made to a memory-mapped file be flushed to disk? I assume that if the OS ensures a memory-mapped file is flushed to disk when the process is killed via SIGKILL, then it will also do so with other terminating signals (SIGABRT, SIGSEGV, etc...). ...

shell history question

I have two commands I execute frequently. Let's say the first is 'abcd' and the second is 'abc'. So my history contains 1000 abc arg1 arg2 arg3 1001 abcd arg1 arg2 arg3 Now if I type '!abcd' in bash, it executes the abcd command. which is fine. But if I type '!abc' in bash, it also executes the last abcd command (since it matches the...

How to pipe list of files returned by find command to cat to view all the files

Hi, I am doing a find and then getting a list of files. how do I pipe it to another utility like cat (so that cat displays the contents of all those files) and basically need to grep something from these files. ...

Most efficient and reliable way to get Unix files into SQL Server

I've got three files on AIX that I need to import into a SQL Server 2005 database. The files are created by an AIX script that I have control over. There are several options that I know will work, but I'd like to find out what others have done before and what works best. Here are the options I'm looking at. Have the AIX script sftp th...

AIX deployment : installp or rpm?

I am deploying a large set of perl/shell/sql code on AIX. these could be (and are) different applications with their own dev teams, source control repos, etc. I am lazy and want to make deployments/roll-backs easier - and I am digging towards rpm packaging with all it's +/- benefits. AIX native system of packaging is installp (with bf...

Transferring files from AIX batch to Windows batch

The responses to my previous question suggested SSIS as the most efficient and reliable way to get files from AIX into SQL Server. I agree that it's probably a good idea. But for the sake of understanding the other options better, I'd like to narrow the scope a little bit. Irrespective of what I plan to do with the files, how can I dete...

Handling ungraceful shutdowns when using fork and sockets

I have a server that listens for socket connections and perform different kind of actions, depending on the request. One of them is long lived database queries, for which the server forks. The server keeps a log of all the active children and whenever asked to shutdown, it will kill all it's children before exiting. A couple of times I ...

C Timer Callback

Interested in something similar to JavaScript setTimeout in C on both UNIX and Windows. Basically, I want: start_timer(&function_pointer, int time_in_secs) or as close to that as I can get. Also, something similar to setInterval would be nice (where it calls the callback every n seconds), but that can be implemented using setTimeout...

Fish Interactive Shell full path

Is there a way in the Fish Interactive shell for the full path to be displayed. Currently when I navigate to a directory I get the following shell. millermj@Dodore ~/o/workspace but I would rather see millermj@Dodore ~/o-town/workspace ...

Why ssh fails from crontab but succedes when executed from a command line?

I have a bash script that does ssh to a remote machine and executes a command there, like: ssh -nxv user@remotehost echo "hello world" When I execute the command from a command line it works fine, but it fails when is being executed as a part of crontab (errorcode=255 - cannot establish SSH connection). Details: ... Waiting for serve...

How to do asynchronous inter thread communication on platform with pthreads

For example on windows there is MsgWaitForMultipleObjects that lets you asynchronously wait for windows messages, socket events, asynchronous io (IOCompletionRoutine), AND mutex handles. On Unix you have select/poll that gives you everything except possibility to break out when some pthread_mutex is unlocked. The story: I have applica...

unistd.h read() is reading more data then being written

I'm reading/writing data off of a named pipe. On the writing side it says that it's writing a constant 110 bytes. On the Reading side for the majority of time it says that it's reading 110 bytes which is correct, but other times it says its reading 220 bytes or 330 bytes. Which is right in the fact that when I print it out it's printing ...

Change current directory from a script

Hi, everybody! Is it possible to change current directory from a script? I want to create a util for directory navigation in bash. I have created a test script that looks like the following: #!/bin/bash cd /home/artemb When I execute the script from the bash shell the current directory doesn't change. Is it possible at all to change...

Admin privileges for script

Hello, how can i check admin-privileges for my script during running? ...

Does this multithreaded program perform better than the non-multithreaded one?

A colleague of mine asked me to write a homework for him. Although this wasn’t too ethical I did it, I plead guilty. This is how the problem goes: Write a program in C where the sequence 12 + 22 + ... + n2 is calculated. Assume that n is multiple of p and p is the number of threads. This is what I wrote: #include <pthread.h> #include <...

Unable to change a pipe to be a normal file

I have the following file (above) which seems to be an Unix pipe How can you make the pipe a default text file? ...

command line to get the memory used by process

What command line should I write to display the memory used by process as well as the process command line and it's pid ? Something like: pid mem cmdline --- --- ------- 112 12M mysql -param1 5 -param2 12 115 15M apache -param1 44 -param2 8 ... ...

unix ls sort by name

Can you sort ls listing by name? Amazingly enough (Or I must be brain-dead) I dont see anything in man pages or can find anything on google :) ...

How to tell if stderr is directing output to a file?

Is there a way I can tell whether stderr is outputting to a file or the terminal within a C/C++ program? I need to output different error message depending on whether the program is invoked as: ./program or like: ./program 2>> file ...

How to redirect Dtrace output when using the -c flag?

How can I redirect only Dtrace's output when running a script with the -C flag? like in this case: dscript.d -s myscript.d -c date Note: I found the answer to my question before posting it, but I'm putting it here so it's part of SO. ...