Perl's system() starts a process, but breaks the parent/child relationship?
test.pl:
use POSIX;
system("./test.sh &");
my $pid = `ps -C test.sh -o pid=`;
print "pid: -$pid-\n";
waitpid($pid, 0);
test.sh:
while true
do
sleep 1
done
When I run test.pl, it finds and prints a correct pid of test.sh. But waitpid() returns -1 an...
I have a pthread_t, and I'd like to change its CPU affinity. The problem is that I'm using glibc 2.3.2, which doesn't have pthread_setaffinity_np(). That's OK, though, because pthread_setaffinity_np() is itself a wrapper of sched_setaffinity(), which can be called by passing a thread ID instead of a process ID to set the affinity for an ...
Hi,
Suppose I have a code executed in Unix this way:
$ ./mycode
My question is is there a way I can time the running time of my code
executed K times. The value of K = 1000 for example.
I am aware of Unix "time" command, but that only executed 1 instance.
...
Why can't internal unix commands (cd, pwd, etc) be run directly in java like external commands (chmod, chown, etc) using Runtime.getRuntime().exec() ?
Please help with explanation.
...
The UNIX "/usr/bin/script" command will create a running transcript of your shell session (see "man script" for more info).
However, when inside a script instance, it seems to forget the parent shell's env vars, aliases, etc.
The following example demonstrates how the "ll" alias I define is ignored inside "script":
zsh> mkdir temp
zsh...
Recently I was looking at the 'dirent' structure (in dirent.h) and was a little puzzled by its definition.
NOTE: This header file is from a Solaris machine at my school.
typedef struct dirent {
ino_t d_ino;
off_t d_off;
unsigned short d_reclen;
char d_name[1];
} dirent_t;
Particularly the d_name field. How would t...
I enjoy using UNIX/bash commands that support coloured output. Consequently, I have a few aliases defined which automatically enable coloured output of the commands that I know support this option. However, I'm sure there are hundreds of commands out there that support coloured output - I'd like to know what they are.
The ones in my ~...
Hi,
I have a following input data:
AATGCCACGTTGAGAGGCGTTCGCGGAAGGCGCG 44 40.000
AATGCCACTCGGGTCCGAGATGGCGGATCTCCAC 35 37.000
AATGCCAGAGCTGTGGTAGTGTGAAAGCAGCAGT 13 13.000
What I want to do is to substract column 3 by column 2
yielding:
AATGCCACGTTGAGAGGCGTTCGCGGAAGGCGCG -4
AATGCCACTCGGGTCCGAGATGGCG...
I'm trying to write a lua script that reads input from other processes and analyzes it. For this purpose I'm using io.popen and it works as expected in Windows, but on Unix(Solaris) reading from io.popen blocks, so the script just waits there until something comes along instead of returning immediately...
As far as I know I can't change...
When I do this:
find . -name "pattern" | grep "another-pattern"
Are the processes, find and grep, spawned together? My guess is yes. If so, then how does this work?:
yes | command_that_prompts_for_confirmations
If yes is continuously sending 'y' to stdout and command_that_prompts_for_confirmations reads 'y' whenever it's reading it...
Hi all,
I have 4 '.cpp' files and 1 header files:
Tools.cpp
Code1.cpp
Code2.cpp
Code3.cpp
and Tools.hh
Now all Code1.cpp, Code2.cpp, Code3.cpp
use functions stored in Tools.cpp.
Currently, what I do to compile all of them is using
this simple shell script:
#!/bin/bash
echo "compiling Code1.cpp";
g++ Code1.cpp Tools.cpp -o Code1
e...
Hi,
I am a newbie in C++ programming.
When compiling I never use any option.
This is my day to day command:
g++ MyCode.cc -o MyCode
For safety practice what's the best option
to use?
...
Is there any way a script can be made that copies files from a Unix drive onto a Windows drive?
...
Is there a command line tool for unix and windows that uses the same algorithm to create GUIDs for both platforms?
...
Hi all,
How can we create a software package. So that
after extracting our software tar ball user can do
the typical steps:
$ gunzip < mycode.tar.gz | tar xvf -
$ ./configure
$ make
$ make install
...
Currently my "info" command uses Emacs as its default editor.
$ info printf
Is there a way to change it into Vi/Vim?
...
I'm debating whether I should learn PowerShell, or just stick with Cygwin/Perl Scripts/Unix Shell scripts, etc.
The benefit of PowerShell would be that the scripts could be more easily used by teammates that don't have cygwin; however, I don't know if I'd really be writing that many general purpose scripts, or if people would even use t...
Hi all,
Here is a query:
grep bar 'foo.txt' | awk '{print $3}'
The field name emitted by the 'awk' query are mangled C++ symbol names. I want to pass each to dem and finally output the output of 'dem'- i.e the demangled symbols.
Assume that the field separator is a ' ' (space).
...
I have been using 'bash' since the time I have been using Unix- Linux/Solaris. Now, I am interested to know what do shells like 'ksh','zsh' offer better? What do 'geeks' use?
...
Hello, I would love to learn to program in pure UNIX with C kernell calls and all this, but I basically don't know where to start...
Books are usually the best way, so that's why I'm asking for one - but some good online material would be OK too. But please, no wikipedia - I don't want an encyclopedia, I want some book to guide me throu...