Programming :: Why New Threads Exit When Main Thread Exit
May 22, 2010
In linux, creating thread is same as process (clone()), except the virtual address space gets shared with the parent.If a running main process(thread) creates new thread, and if main thread exits, why should the new thread too exit? both are different entities, The same doesn't happen if the child thread exits, the parent thread would be alive.
View 1 Replies
ADVERTISEMENT
Apr 11, 2010
I noticed that if I have "exit" in a bash script file., e.g. script.sh,that when the word "exit" is reached, and the script file being executed is not in the PATH nvironment, i.e. ". script.sh", the whole konsole shell profile is exited! What gives here? Is there another command compatible to "exit" to prevent this, or will I just have the leave the "." part in the PATH enviroment, which is, to my understanding, is not recommended? I desire for a "goto" function in bash script files
View 11 Replies
View Related
Jun 28, 2011
I learn C++ reading the <C++ primer 4th>, question1.2 let me test if return -1 how the compiler handle this exit code.
and in gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52), I get this show:
[youxi600@Arthas C++ Primer]$ cat q1_2.cpp
int main()
{
return -1;
}
[youxi600@Arthas C++ Primer]$ gcc q1_2.cpp -o q1_2
[youxi600@Arthas C++ Primer]$ ./q1_2
[youxi600@Arthas C++ Primer]$ echo $?
255
[youxi600@Arthas C++ Primer]$
anyone can give me an advise? Many thanks!
View 13 Replies
View Related
Jun 3, 2011
What are the uses of return 0, return 1 and exit statements in C
View 4 Replies
View Related
Jun 10, 2010
I am running a command pretty similar to the one below:
Code:
I need to capture the exit status of that part of the command.
What I am trying to do is set a variable that can be modified within my_job.sh, and used to exit.
However, no matter what I set "status" to in my_job.sh, it exits with "0".
What can I do differently?
View 3 Replies
View Related
Mar 3, 2010
How exactly can I use the exit status of a command in an if statement ?
Something like this:
Code:
View 3 Replies
View Related
Jun 7, 2011
I am using a program that reads in data from a serial port and then sends that data out over a TCP connection. The problem I'm having is that the only way I know to exit the program is to do a 'kill PID', but doing this means the program doesn't go through the motions of closing the TCP connection properly so I have to wait some random period of time for the port to free itself or else when I try to start it back up it tells me that it can't bind to the specified port.The general structure of the program is as follows
Code:
int main(){
// initialize some stuff
[code]...
View 1 Replies
View Related
Jul 6, 2009
I am trying to write a python script which logs into a NetApp filer and fetches some data. I am using the telnetlib library. Filer does not take exit command. So it expects Control-D. How to send that via python script?
View 5 Replies
View Related
Nov 18, 2010
I have this command in ksh:
1. typeset -i INTEGER INTEGER=aaa In all platforms except of Linux it is failing and return exit code 1 Why in Linux it is not failing? I must it for my number tests
2. The same for printf command. Only in Linux the bellow command is not failing: printf "%d" aaa
View 7 Replies
View Related
Dec 26, 2010
I'm new to scripting and I have a trouble with if statement syntax. The code is: Code: #there is a diff command here, and it does what i want but#i wanna see 1 if the exit value of diff is 0, and otherwise i wanna see 0.#the problem is here: (syntax error near unexpected token "then")
if["$?"==0];
then
echo 1
[code].....
View 1 Replies
View Related
Sep 24, 2010
i am wondering why the following simple code causes a segfault on exit,when the std::string destructor is called.
Quote:
#include <iostream>
#include <string>
using namespace std;
[code].....
I guess the memset messes with some internal std::string's data structures/pointers. I personally am anti-memset,and always avoid them.
View 4 Replies
View Related
Jul 1, 2010
Is there a way to count the number of errors- an exit variable $? from one function?
The output from the exit variable (either erroneous or correct (1) or (0)) is it possible to add the erroneous one ups?
View 3 Replies
View Related
May 14, 2010
How do i run a part of code on exit in a shell script?Suppose i have four echo statements like the following:
echo "Stmt 1"
echo "Stmt 2"
....some code goes here...
[code]...
View 2 Replies
View Related
Jul 3, 2009
Consider the following code:
Code:
...
int ret=0;
[code]...
View 4 Replies
View Related
Mar 16, 2011
I have a problem with the last point of some homework I have for an OS class. I need the program to print the pid upon execution, then for 10 seconds react to SIGUSR1, SIGUSR2 and SIGTERM. If either USR1 or USR2 is received, the 10 seconds are reset. Some of the functions I'm told to use are alarm(), pause() and signal(). The nicest way I found was to handle SIGUSR1, SIGUSR2 and SIGALRM in the parent process, with SIGALRM killing the child (with a SIGTERM). In the child a pause() (or for(; pause() would be enough for it to be alive until killed from the SIGALRM handler in the parent.
What I found is that I can't just do a wait() in the parent process, waiting for the child to be killed, since whenever the parent receives a SIGUSR1 or SIGUSR2, the right handler is called but the child exits nicely. I tried blocking/ignoring those signals in the child, since the default behaviour for SIGUSR1 and SIGUSR2 is to terminate the process, but the result is the same. The only way I could do it is using a waitpid() within a do { } while(!WIFSIGNALED(status)) since when the child gets killed with the parent's kill(), it's WIFSIGNALED, whereas when it exits after the parent handles a SIGUSR1/2, it's WIFEXITED.
P.S. What I'm doing to achieve the expected 10s window is calling alarm(10) in the parent process and again within the SIGUSR1/2 handlers. In the SIGALRM handler I kill the child and within the child I simply do a for(; pause()
View 4 Replies
View Related
Apr 10, 2010
I have a scenario where I am executing some child shell scripts in background (using &)through a master parent script.
Is there a way I can capture the exit status of each individual child script after the execution is completed.
View 7 Replies
View Related
Dec 4, 2010
It's called TextRipper and it creates indexable and editable text files from any image. Feel free to copy TextRipper; it's licenced under GPL. My troubles are with cracking passworded pdf's. (As you can see, I meant any when I said any image.)
I can't find a way for the user to cancel the decryption process by exiting the script without pdfcrack orphaning. Line 349 works the rest of the time; the concerned process is line 228. I believe it's a piping/subshell problem. At least that's how I've been going at it in vain.
I've made portability a priority and that the comments still require updating.
Code:
If the result is one output file, TextRipper will open it for you in OpenOffice Writer.
Otherwise all txt output files (editable and indexable) will be in the original file's directory." 0 0
View 14 Replies
View Related
Mar 22, 2011
I have not been able to write bash to use a PID file to ensure no other instance of the same script is running! All three methods I can think of to see if the PID in the PID file is another instance of the script make the script exit with a return code of 1 but the same commands run at the command prompt work as expected.
The first attempt was:
Code:
The first attempted workaround was:
Code:
The second attempted workaround (with debug to make the following command prompt copy and paste meaningful) was:
Code:
Here's the command prompt session, testing with a stale PID file and then manually running the problem command and it behaving as expected:
Code:
This on Slackware64 13.1 which has bash 4.1.7.
In desperation I tried rebooting but the behaviour was the same.
View 2 Replies
View Related
May 2, 2010
Whenever I'm running my application process, I've 1M physical memory usage is increasing for every 2 hours.This I observed using 'free -m' command.But 'top' command did not showing any increase 'RSS' size.It is same as it was started initially.Even though I stopped my process,the increased memory was not released back. If I start my application process then again memory usage start increasing by 1M for every 2 hours. increase of memory usage observer with 'free' and that too when my application is running, but top command is not showing any change in the RSS sizeIf my application is leaking any memory which is allocated by new/malloc, that should be released back whenever my application exit and the size increase will be show through top command for that process, right? This is not happeningThis proves that there is no potential leaks in my process.But why physical memory is increasing when only my process is running?
View 14 Replies
View Related
Feb 3, 2011
I am trying to get bash script using zentity to exit if the user presses the cancel or close buttons.The exit codes are working fine; they read 1 or 0 depending on the status but it always assumes 0. This is the portion of the script: PHP Code:
function settings(){
result=$(zenity --height=30 --width=300 --list --checklist --title='Selection'--column=Boxes --column=Selections --column="Options"
[code]...
View 2 Replies
View Related
Dec 25, 2010
I am going to use "pthread_setaffinity_np" to bind a thread to a specific core. My application has two threads. I have used mutex to assign a specific id to each thread and then bind that thread to a core different from another core. but it seems that the os assigns both thread to one core.What should I do to bind each thread to a specific core?
View 4 Replies
View Related
Mar 18, 2010
I was wondering how you exited x server in ubuntu. I relatively new to linux. I wanted to install the newest nvidia driver, and they said you needed to exit x server when running the driver installer. Someone already told me to try ctrl-alt- F6, which didn't work. That just put me in a virtual terminal that still had x-server running. So if anyone knows how to exit x-server,
View 1 Replies
View Related
May 1, 2010
What are exit handlers ? They are piece of code to execute prior to exit() ?
View 3 Replies
View Related
Nov 29, 2010
Here I was, having problems with the resolution then I stopped the X server as was instructed at the tutorial. I followed it all then rebooted. But I found that even after reboot, I'm still stuck with TTY. I clicked Ctrl Alt F7 but still it's a terminal and it did not return to the GUI or the normal desktop. What will I do to exit it? It's a good thing I have windows vista along with it or else I'll now have a computer that I can't use outside the terminal.
As nothingspecial said, I should place the link of the tutorial I was following: [URL]
View 4 Replies
View Related
Mar 3, 2011
i have upgraded vlc 1.1.4 to 1.1.7....but im having a problem regarding the 1.1.7 version. the vlc(1.1.7) is crashing on exit.
View 1 Replies
View Related
Aug 3, 2010
I use fedora 9 and want exit from x server. when i use init command,show me error.for use init command in fedora 9 what work?
View 4 Replies
View Related
Jan 20, 2011
I have a (Verbatim, if it matters) USB drive which previously worked with Linux just fine.However, since then I have formatted my drive, and it currently has no partitions on it. I would like to not use a cd to test out Salix, and to use Unetbootin with my USB to install Salix. However, when I plug in my USB it does not mount. Running sudo fdisk -l only gives my hard drive, and neither Gparted or Unetbootin can find it. I'm currently running Xubuntu 9.10, if it matters.
View 9 Replies
View Related
Feb 11, 2011
When I run my script(attachment) and I use an option(-l -u -r) that requires an argument, it should exit if the argument isn't supplied, but it doesn't. How do I arrange this?
View 1 Replies
View Related
Mar 25, 2010
We have two types of servers RHEL5 and RHEL4 as well as Fedora 11 desktops.
After a period of inactivity, trying to exit from "su - <username>" causes the system to hang for about 10 minutes. It takes that long before the prompt comes back. Here are a few items that noticed as I have tried to trouble shoot this problem. The prompt always comes back if you wait long enough It only happens on RHEL 5. RHEL4 and Fedora 11 are unaffected It does not appear to matter what other software is running. Some boxes have databases, others do not It happens to boxes in run level 3 as well as boxes in run level 5 It does not matter if logging in from the console (tty) or from ssh (pts). Both types of logins produce the same result.
It does not matter if the account is an LDAP or a local account. It takes between 30 min and 1 hour of inactivity before the problem occurs Other sessions on the box are completely unaffected. Once hung, I can still log in with a different session without a problem top shows no load while session is hung there are no messages in /var/log/messages, /var/log/secure, /var/log/audit/audit.log or in dmesg if a session is killed, finger shows that it is still logged in a putty log shows that the server is still sending "keep alives" to putty while the session is hung Only su is affected. There is no problem logging out of the box from the initial login account. what I can try in order to trouble shoot this?
View 2 Replies
View Related
May 26, 2011
Ever since Debian updated Fluxbox several weeks ago Fluxbox on my netbook will not exit. I have tried reinstalling it but it still will not exit.
View 14 Replies
View Related