examples/PIPS/posixsignals/sigtermSignal/src/raiseSignal.c

00001 // raiseSignal.c
00002 //
00003 // Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 // All rights reserved.
00005 // This component and the accompanying materials are made available
00006 // under the terms of "Eclipse Public License v1.0"
00007 // which accompanies this distribution, and is available
00008 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00009 //
00010 // Initial Contributors:
00011 // Nokia Corporation - initial contribution.
00012 //
00013 // Contributors:
00014 //
00015 // Description: raiseSignal.c source file
00016 //
00017 
00018 #include <stdio.h>
00019 #include <stdlib.h>
00020 #include <signal.h>
00021 #include <unistd.h>
00022 
00027 void PressKey()
00028     {
00029     int ch;
00030     printf("Press 'e'+Enter to exit\n");
00031     while((ch = getchar()) != 'e')
00032         {
00033         if(ch == '\n')
00034             continue;
00035         else
00036             printf("wrong option inserted, try again!!!\n");
00037         }
00038     }
00039 
00044 int main(int argc,char **argv)
00045     {
00046     pid_t id;
00047     int ret;
00048     if(argc < 2)
00049         {
00050         printf("Please pass the correct arguments\n");
00051         return EXIT_FAILURE;
00052         }
00053     id = atoi(argv[1]);
00054         
00055     printf("*********************In the raiseSignal***********************\n");
00056     printf("\nThis process sends a SIGTERM signal to the sigtermSignal process.\n");
00057     printf("\nPress Enter to send the SIGTERM signal\n");
00058     getchar();
00059     
00060     //Raising SIGTERM signl using kill command.
00061     ret = kill(id, SIGTERM);
00062     if(ret)
00063         {
00064         printf("Kill() failed, errno=%d", errno);
00065         } 
00066     PressKey();
00067     return EXIT_SUCCESS;
00068     }

Generated by  doxygen 1.6.2