Unix/Linux Newbie(ish) Question - IPC/Signals


 
Thread Tools Search this Thread
Top Forums Programming Unix/Linux Newbie(ish) Question - IPC/Signals
# 1  
Old 01-19-2002
Unix/Linux Newbie(ish) Question - IPC/Signals - EDITED, OOPS!

Smilie 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 09:56 PM..
# 2  
Old 01-20-2002
As far as I know ( I'm no expert Smilie ) if you want to work with signals you should
include signal.h
# 3  
Old 01-20-2002
MySQL

Thank you very much, might seem obvious but hey - i'm new to all this.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

C++ signals Linux

how can do this programs in c++ Program description: Infinite loop in a program starts working with 2 seconds the screen (console) "I 'm trying" to write, but it automatically after 10 seconds, the screen "Close" will terminate the execution of typing. c++ code (3 Replies)
Discussion started by: ss54
3 Replies

2. Solaris

errors on Netra-440: "IPC Warning: ipc: tcp_protocol: bad magic number"

I was asked to look into a problem with a Sun Netra 440 in another department. On the server in question, the relevant 'uname -a' information is, "SunOS host1 5.9 Generic_118558-16 sun4u sparc SUNW,Netra-440". That information aside, while the other admin is logged into the ALOM, these errors are... (0 Replies)
Discussion started by: Borealis
0 Replies

3. Shell Programming and Scripting

A question about signals in Unix

Whats a signal 0. An exhaustive search on signals landed me nowhere. Is it possible to do something like this trap "echo $var" 0. If so what signal does this trap catch ? (2 Replies)
Discussion started by: kinny
2 Replies

4. UNIX for Dummies Questions & Answers

UNIX newbie NEWBIE question!

Hello everyone, Just started UNIX today! In our school we use solaris. I just want to know how do I setup Solaris 10 not the GUI one, the one where you have to type the commands like ECHO, ls, pwd, etc... I have windows xp and I also have vmware. I hope I am not missing anything! :p (4 Replies)
Discussion started by: Hanamachi
4 Replies

5. Shell Programming and Scripting

Question using signals in my own shell..

Wasn't really sure where to put this, since I'm using C in UNIX, but I am making my own shell... so, what's going on is this: For our program, we had to create our own shell, and if the user pressed ctrl-c just at the cmdline, then this signal would be ignored, but if there is a foreground... (1 Reply)
Discussion started by: blind melon
1 Replies

6. HP-UX

Question form unix newbie

hi, just starting to learn about unix in school. got stuck on shell script chapter and need some help i completed task one but the other four is byond me. Task 1) Write a shell script/program called dow that takes no arguments and displays just the current day of the week in lower case (i.e.... (2 Replies)
Discussion started by: wesleywu
2 Replies

7. Programming

signals related question

Hi all, Just a little question relative to signals. I know that if an application is in the sleep state, When a signal is catched, it will be processed by the handler. But what happens if it's processing something? Does the processing stops?? The following code should illustrate this case ... (2 Replies)
Discussion started by: ninjanesto
2 Replies

8. UNIX for Dummies Questions & Answers

Newbie's question about COBOL Installation in Unix

I wanna to install a COBOL on the AIX unix server. Would u like to tell me the disk usage of COBOL installation? Thanks in advance. (2 Replies)
Discussion started by: GCTEII
2 Replies

9. UNIX for Dummies Questions & Answers

linux newbie question...

I'm running Vector Linux on this computer, and everythign works fine, except for the NIC. I run netconfig, and then when I reboot it says: DC21140 at 0x9400(PCI BUS 0, device 11) h/w address 00:00:C0:2E:13:dC, and reqquires IRQ 9(provided by PCI BIOS) Setting up net subsytems. ... (5 Replies)
Discussion started by: Corey
5 Replies

10. UNIX for Dummies Questions & Answers

Newbie question about unix flavours

Hi, I am newbie to unix. I am been immensily impressed by this forum. I have installed sun solaris in my pc and started learning unix. The question is, If i know one unix flavour (say sun solaris) is that i can claim, i know all the unix and linux flavours. Can i be able to work on other vendor... (3 Replies)
Discussion started by: Balaji
3 Replies
Login or Register to Ask a Question