The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
signals related question ninjanesto High Level Programming 2 02-13-2007 10:43 AM
UNIX newbie NEWBIE question! Hanamachi UNIX for Dummies Questions & Answers 3 09-14-2006 07:23 AM
Signals in Unix Solaris heljy High Level Programming 1 03-24-2002 10:25 PM
linux newbie question... Corey UNIX for Dummies Questions & Answers 5 02-10-2002 01:31 PM
Newbie question about unix flavours Balaji UNIX for Dummies Questions & Answers 3 11-27-2000 09:12 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-19-2002
Registered User
 

Join Date: Jan 2002
Location: UK
Posts: 6
Stumble this Post!
Unix/Linux Newbie(ish) Question - IPC/Signals - EDITED, OOPS!

Hello, i have been given the following code to help me learn how to use signals, it won't compile. The problem maybe because this was written for use in Unix and i am trying to compile in Linux.

The error i get says that SIGPIPE and SIG_IGN are undeclared.

I think that these are defined in signum.h but am not sure and I can't check as nothing seems to be working at the mo (Triple booting with a couple of Win OS' = Grief). Please can somebody offer me some guidance, you all seem fairly knowledgeable. Apologies if this is all a bit Newbie or i'm being dense, it's all a bit strange.

EDIT- I have put normal brackets instead of the proper ones around my #include's so that they will display.

#include (stdio.h)
#include (stdlib.h)
#include (sys/stat.h)
#include (unistd.h)

#define FIFO_FILE "MYFIFO"
#define FIFO_FILE2 "MYFIFO2"
#define MAXNUM 8

int main(void)
{
FILE *fp;
FILE *fp2;

int i = 1; /* counters */
int j = 1;
int count = 0;
int array[10]; /* array to hold converted numbers */

signal(SIGPIPE, SIG_IGN);/* tell kernel to ignore a broken pipe */

/* Create the FIFO's if they do not exist */
mknod(FIFO_FILE, S_IFIFO|0666, 0);
mknod(FIFO_FILE2, S_IFIFO|0666, 0);

while(1)
{
/* Open the FIFO's here */

fp = fopen(FIFO_FILE, "r");
fp2 = fopen(FIFO_FILE2, "w");

/* Read in the array sent from Detector */

fread(array, sizeof(array), 1, fp);

/* here we cheek the values of the array.
If equal 2 write to the out FIFO so that
it can be read by display */
count = 0;
for (j=0; j < 9; j++)
{
if(array[j] > MAXNUM) count++;
else count = 0;
}

if(count == 2)
{
fwrite(array, sizeof(array), 1, fp2);
fwrite(NULL, 0, 1, fp2);
}

fclose(fp);
fclose(fp2);
}

return(0);

}





I don't want to sound rude but help other than 'go find X book' would be preferable as I would rather not wait 2 weeks to get one ordered.

Thank you kindly in advance[

Last edited by theultimatechuf; 01-19-2002 at 05:56 PM.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 01-20-2002
Registered User
 

Join Date: Jan 2002
Location: romania
Posts: 10
Stumble this Post!
As far as I know ( I'm no expert ) if you want to work with signals you should
include signal.h
__________________
I like living single, drinking double and sleeping triple.
Reply With Quote
  #3 (permalink)  
Old 01-20-2002
Registered User
 

Join Date: Jan 2002
Location: UK
Posts: 6
Stumble this Post!
Thumbs up

Thank you very much, might seem obvious but hey - i'm new to all this.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:33 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0