Background program exits prematurely?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Background program exits prematurely?
# 1  
Old 03-06-2010
Background program exits prematurely?

Hello! I am currently attempting to build a very, very, basic program that attempts to act like a calendar for a "server." Using this program I need to have the client program connect to the server program, have the client wait for the server to respond through a socket, then exit and the server continues its operation.

I could post code/files, however I feel as if this is a simple mistake that I am overlooking because I am too close to the project. My question is: why is the "server" program exiting prematurely and not looping indefinitely (which I assure you it is coded to do). In addition, the "server" program is ordered to run in the background (compiled with the syntax "./server.out 2300 &" with 2300 being the socket number)

An example of the error messages I am receiving are:

[1]+ Exit 1 ./server.out 2300
(this one occurs 90% of the time)

and the others are variations of this one... just instead of [1] it may be [2] or [3] and rarely the '+' becomes a '-' (minus).

HELP!

Thanks Smilie
# 2  
Old 03-06-2010
Error

I this may be the problem with the NONBLOCK mode in your code.So your server program comes out when no client are immediately available.Change it to BLOCK mode.
If it is not a problem post your code .
# 3  
Old 03-06-2010
Cont'd

Thanks karthigayan, attached is the entire file that is my "server."

As a note, some trouble shooting with a script for multiple events shows that the coding for:
Code:
strcat(returnBuf, "Write successful!\n") ;
if( write(ssock, returnBuf, sizeof(returnBuf) ) < 0) ;
{
  errexit("mycald write: %s\n", strerror(errno) ) ;
}
return 0 ;

Is somehow at fault (yes... this little section is repeated MANY times as it is the only way to communicated from server->client.) The script shows that "Write successful!" prints out, however then the phrase "mycald write: Success" prints and then the server program is terminated. As you can see... that corresponds to the error message, however that shouldn't be an error! (especially since it even says Success in it)

Last edited by Scott; 03-06-2010 at 06:52 AM.. Reason: Please use code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Run interactive program in background and grep it

I need to run an interactive program in the background so I can grep it for specific data to use for some logic in a script. There is no quiet or background mode on the program so I plan to redirect a document with commands in it and then to grep the output. This is almost working, except... (1 Reply)
Discussion started by: doonan_79
1 Replies

2. Shell Programming and Scripting

Reading from a file a background program writes to

Hi! #!/usr/bin/env bash rm tmpcomm nc -v -u -l 444 | hexdump -b > tmpcomm while : do read l1 < tmpcomm read l2 < tmpcomm read l3 < tmpcomm read l4 < tmpcomm # do something doneI start netcat in the background and listen for an incoming conncetion. All incoming... (1 Reply)
Discussion started by: torax123
1 Replies

3. UNIX for Dummies Questions & Answers

Cygwin not waiting for program in background (solved)

Hello, I know this isn't exactly a Unix question, but I wasn't able to find much information elsewhere. I'm trying to run a program in the background using Cygwin on a Windows machine, then use the wait command to pause before proceeding. Unfortunately, as I've confirmed using ps aux, the... (0 Replies)
Discussion started by: ocdcollector
0 Replies

4. Shell Programming and Scripting

How to process and run a program in the background in perl?

Hi, I have a query about processing and running Perl program at the background. I have HTML file called Userform.html which accepts input from the user. As soon as input is given the contol goes to get.cgi (get.cgi does some processing and computing tasks). Actually get .cgi takes more... (0 Replies)
Discussion started by: vanitham
0 Replies

5. UNIX for Advanced & Expert Users

script dies prematurely and unpredictably

Hi, I have over 5 gb of data in a files structure in which month folders are in year folders, day folders are in month folders, and individual climate stations are in each day. I am trying to extract precipitation measured at 5 minute intervals for a duration of 15 years, but the script never... (2 Replies)
Discussion started by: mlw63@me.com
2 Replies

6. Infrastructure Monitoring

Nagios escalating prematurely

We are currently using Nagios 1.3 .The issue we facing is , when a alert is in Warning state and then from Warning it moves to Critical state ,the alert is escalated directly to L2,L3 L4 escalations,here nagios assumes that the time period ,the alert was in warning state as unacknowledged time... (0 Replies)
Discussion started by: apatil
0 Replies

7. Shell Programming and Scripting

Start program in background (or start crontab ahead of time)

Hey! I'm working on a script that will add a user, create some configfiles, and add a crontab for the user. The crontab looks like the following: @reboot /home/user/program config.conf & I would like for this process to start at the end of my script under the corresponding username by... (0 Replies)
Discussion started by: noratx
0 Replies

8. Programming

Run external program in background

Hi, in my program i need to run an external program in background.I am aware that there are at least 2 alternatives for this: 1)fork+exec 2)system("program &"); I have read several posts about this,and they all tend to suggest to use fork+exec (and that's what i am doing now). I have some... (2 Replies)
Discussion started by: Zipi
2 Replies

9. Programming

nanosleep returns prematurely, with return value 0

Hi, I have encountered the following problem on Solaris 10: I have a thread that is asleep on nanosleep (set to 24 hours). Something that happens on another thread, causes the nanosleep to exit, even though the time has not elapsed. The returned value is 0 (so it doesn't look like it... (1 Reply)
Discussion started by: MeMyself
1 Replies

10. Shell Programming and Scripting

Why does rexec cause while loop to end prematurely?

I have the following korn shell script which reads the contents of an ascii file and performs an rexec command based on the line that was just read from the ascii file. The ascii file contains 6 lines, thus, the while loop should execute 6 times. The problem is that the rexec command within the... (2 Replies)
Discussion started by: sadove
2 Replies
Login or Register to Ask a Question