LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-08-2002, 03:29 PM   #1
nerak
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Rep: Reputation: 0
C system call in linux


Hi all :>

I have a C program that runs fine by itself, but when I put it to run automatically when the computer boots up, Linux doesn't recognize the system("blahblahblah") call...can anybody help?

I put the program in the /etc/init.d folder and created a symbolic link in the /etc/rc.d/rc#.d as well.

Thanks in advance.
 
Old 04-08-2002, 03:36 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well what is the line?? remember you'll not have the path set up and all that. any calls should be absolute
 
Old 04-08-2002, 03:40 PM   #3
nerak
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Original Poster
Rep: Reputation: 0
well, the rundown of my program is this:

- i have a shell program in the init.d folder that calls a C program (works) in the background
- the C program listens on a port and calls system("netscape") when some signal comes from the port (help help)

does this clarify things a bit?
 
Old 04-08-2002, 03:43 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,378

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
well... it's not absolute is it???
 
Old 04-08-2002, 04:04 PM   #5
nerak
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Original Poster
Rep: Reputation: 0
ohh >_<

i just tried changing the system command to system("/usr/bin/shutdown -r +5") to give it an absolute path...but my program is still not shutting down when the signal is activated!!

help help...
 
Old 04-08-2002, 09:33 PM   #6
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
Is your program using signals or does it use sockets (listen on a port)? Your terminology is a bit confusing.

If you are using signals you are using the signal call:
Code:
signal( SIGUSR1, sig_usr1 );
If you are using sockets to communicate (unnecessary complication for simple IPC on the same machine) you will have:
Code:
socket( AF_INET, ... );
bind( ... );
Or are you using both?

Also, I'd recommend using exec instead of system.
 
Old 04-10-2002, 03:04 PM   #7
nerak
LQ Newbie
 
Registered: Apr 2002
Posts: 6

Original Poster
Rep: Reputation: 0
hey i used the "execl" command and my prog works now :> just wanted to say thank you~
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding system call in linux guam Programming 2 12-04-2004 01:38 PM
how to use ls in a system call in C in linux newguy21 Programming 15 08-01-2004 01:38 PM
linux system call to detect changes in a directory lucianomx Programming 4 06-05-2002 06:54 AM
open system call in linux udayan Linux - Newbie 1 05-06-2002 10:21 AM
adding system call in linux udayan Programming 1 05-02-2002 03:26 AM


All times are GMT -5. The time now is 10:33 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration