C :: Program To Recognize Pattern Of Signals (linux Environment)

Mar 6, 2015

I need to write a c program that can receive signals and recognize a certain pattern (SIGUSR1, SIGUSR2, SIGUSR1, SIGUSR2). once the pattern is caught the program terminates itself.

I am able to send the signals to the program from a different process, but I am unsure on how to get the signal handler to recognize the pattern. here is what i have so far:

Code:
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
sig_atomic_t sigusr1_count = 0;
sig_atomic_t sigusr2_count = 0;

[Code] .....

I just need getting the program to be able to catch that specific pattern.

View 4 Replies


ADVERTISEMENT

C :: Language Program Environment Does Nothing To Prevent Buffer Overflows

Sep 25, 2013

TheC language program environment does nothing to prevent buffer overflows ..... is there any pros to the obvious cons of this?

View 3 Replies View Related

C# :: Windows Task Scheduler Recognize That A Program Has Failed?

Feb 23, 2015

My use case is this: I have a C# Console application. I would like to run it via the Windows Task Scheduler, and would like it to attempt to run until it succeeds. My problem is that I can't achieve this. How does the Windows Task Scheduler recognize that a program has failed? I tried returning 1 or 32 instead of 0 but that didn't work. One possibility is to have the rerun logic in the C# console application but it feels like there must be a better way.

View 6 Replies View Related

C++ :: Using Signals On Windows

Oct 12, 2012

I'd like to compile following code:

Code:
sigfillset( &sa.sa_mask );
sa.sa_handler = &CDevice::PipeHandler;
sa.sa_flags = 0;
sigaction( SIGPIPE, &sa, NULL );
sa.sa_handler = &CDevice::TerminatorHandler;
sigaction( SIGQUIT, &sa, NULL );
sigaction( SIGINT, &sa, NULL );

Using MSVC 2010 to run on Windows 7. Is it possible?

View 1 Replies View Related

C :: Use SIGNALS To Control Threads

Nov 11, 2013

I've to use SIGNALS to control threads. Here's my code without the use of signals as I'm no good at that

Code:

#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
}

[code]....

View 4 Replies View Related

C :: Program That Lets To Download Torrents On Linux

Mar 22, 2013

I want to create a program that lets you download torrents on linux ... how to start ...

View 1 Replies View Related

C/C++ :: Program To Print Irregular Star Pattern?

Oct 5, 2014

I am trying to write a program that will make a pattern of stars. The last line is really tripping me up. I have to make the code only using the printf("*"); printf(" "); printf("/n"); statements once. I want to accomplish this with a for loops and if statements.

It is supposed to look like this:

* - 5 spaces before *
* * - 4 spaces before *
* * * - 3 spaces before *
* * * * * * - 0 spaces before *

This is what I've tried so far:

main()
{
int i, j, k;
i=1;
j=1;

[Code]....

here are the links on codepad [URL]

I think my first approach is way off. But I think I am on to something in the second link. I'm trying to print the "*" and extra 2 times on the fourth line. In the second link the compiler appears to be ignoring the || operator. Is my syntax incorrect in the second attempt? How should I change my if statement to make this pattern work?

View 2 Replies View Related

C :: Program To Check For Running Pid Using System Call In UNIX / Linux

Dec 11, 2013

I have written a program which uses a pid to check if the process is currently running and return a value based on the system call result.But the program core dumps

Code:

#include <stdio.h>
#include <string.h
int main( argc, argv )
int argc;
char * argv[];
{
int p_pid = 99;
char buff[1000];
}

[code]....

What is the mistake in this code and is it portable in both unix/linux , is the method secure (grepping for program name )?

View 6 Replies View Related

C :: Gzip System Linux - Program To Unite 2 Commands Into 1 Command

Sep 15, 2013

I'm writing a program to turn the two commands "gunzip file.tar.gz" then "tar -xvf file.tar" into "x file.tar.gz", but I've ran into a problem I can't find a solution to, here are the outputs I get depending on if I use a gunzip -f flag in my system() call or not:

if I use: (void)system("gunzip ", store );
> x file.tar.gz
gzip: compressed data not read from a terminal. Use -f to force decompression.
type: gzip -h
store 1: file.tar.gz
tar: option requires an argument -- 'f'

[code]....

I don't know if the problem is something to do with my code or something to do with gunzip and if it is to do with gunzip if I can even solve it with my code? I've tried for a while to find more info and read the gunzip man file, ran "gunzip file.tar.gz" outside of my program and found that it works normally producing file.tar so I suspect the problem is related to system()?

View 3 Replies View Related

C++ :: Program To Search Index File Using Command Line In Linux

Oct 28, 2014

I have code that creates an index file created from a data file of records.

#include <iostream>
#include <fstream>
#include <map>
#include <sstream>
#include <string>
#include <iomanip>
using namespace std;
class Record {

[Code]...

I now need to write a second program that allows the user to enter a command on the Linux command line such as

search 12382 prog5.idx

and returns the information for the record with that key. The code I included for the index file is correct and works properly, but how to write the second program.

Here is the index file created by the first program:

8: blank 0 $ 0.00
12165: Item16 30 $ 7.69
12345: Item06 45 $ 14.20
12382: Item09 62 $ 41.37
12434: Item04 21 $ 17.30
16541: Item12 21 $ 9.99
21212: Itme31 19 $ 8.35
34186: Item25 18 $ 17.75
41742: Item14 55 $ 12.36

The top line is a dummy record, the first number is the size of the file.

View 19 Replies View Related

C++ :: How To Have Console Recognize Every Word

Apr 6, 2013

#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;

int x;
string favword;

[Code] ....

I want this program to be able to recognize if a user types in any word ex. (apple, tree, house etc..) and print "system error" if a word is recognized not to be a number. The bold section of code is my failed attempt to try this. Basically I need to know what to make

(x = ?(every word)) in order to finish my console program.

View 1 Replies View Related

Visual C++ :: Recognize WAV File?

Mar 28, 2013

I need to develop an application in VC++ that will take .WAV files as an input and identify if there is a Gun shot in that wave file. WAVE file with gunshot must be having certain paramaters like frequency, bit rate etc which I don't know right now. But is there a way in VC++ to develop a program that can recognize gunshots by comparing that .WAV file with certain parameters?

View 3 Replies View Related

C++ :: Debug Multithreaded Application In Unix Environment?

Mar 3, 2013

How can we debug the multithreaded application in unix environment?

View 1 Replies View Related

C++ :: Handle Exception In Multi-threaded Environment

Oct 24, 2014

Here is the code,

Code:
void foo() {
Acquiring lock
do something...
Func();
Releasing Lock
}

If the function Func throws an exception, there is potential deadlock issue. Then I handle exception like this,

Code:
void foo() {
Acquiring lock
do something...
try{
Func();

[Code] ....

Is this a good practice? I wonder how I can apply RAII in handling exception here.

View 2 Replies View Related

C :: GCC Does Not Recognize Lib Location - No Such File Or Directory

Aug 19, 2013

I have my libraries in ../../lib location

and when i try to compile :

gcc -O9 -I ../../include/ -L ../../lib/ -o test test.c thr.o -lm -lthread

I get :

gcc: error: thr.o: No such file or directory

obviously the problem is the library path location but my obj is there

ls -al ../../lib/ | grep thr.o
-rw-rw-r-- 1 xxxxxx xxxxxx 23544 Aug 12 23:03 thr.o

????

View 2 Replies View Related

C :: Function Which Can Recognize Whether A Word Is Palindrome

Jun 24, 2013

I'm trying to write a function which can recognize whether a word is a palindrome. if it's the case , it must return 1 on screen, otherwise 0. This is the code which return 0 even in case of a palindrome...

Code:
int IsPalindrom(char String[]){
int i,l;
int counter=0;
for(i=0;;i++){ //counts the number of array elements

[Code] ....

View 9 Replies View Related

Visual C++ :: Floating CDialogbar On Multiple Screen Environment

Jul 11, 2014

I have an problem with a CDialogbar if my app runs on a system with two screens (side by side). I can not resize it while the CDialogbar is in floating state on the second screen.

I figured out that the problem is the mfc-function CDockContext::Stretch().

It limits the CDialogbar to the primary screen (using ::GetDesktopWindow() to verify the position).

What can I do?

View 2 Replies View Related

Visual C++ :: Dragging And Dropping Functionality In Windows 8 Environment

Jul 14, 2014

i have developed an application in which i have icons in left side pane of application which can be dragged and dropped in client screen. Application is working fine with all the resolution except 1920x1080.

when setting the resolution to 1920x1080 while dragging icons to client area, icon is not attach to mouse pointer. instead there is a gap between the mouse pointer and the icon. i wrote code to identify the screen resolution but it does not seem to recognize 1920x1080 resolution. below code is giving incorrect resolution for 1920x1080 setting.

RECT actualDesktop;
GetClientRect(GetDesktopWindow(),&actualDesktop);

value of 'actualDesktop' variable is {top=0 bottom=783 left=0 right=1536} which is incorrect. according to current resolution size value should be {top=0 bottom=1080 left=0 right=1920}. Due to this, all the icons while dragging are adjusting according to incorrect resolution setting.

how to identify the issue and if there is any limitation with respect to screen resolution in VC++ 6.0 with windows 8 environment.

I am getting same issue when compiling in VS2012 in windows 8. Code does not seem to recognize 1920x1080 resolution setting and downgrading my application look and feel by setting it to lower resolution.

View 1 Replies View Related

Visual C++ :: Static Class Member In Multithreaded Environment

Nov 21, 2014

I have a class having static member.I have get and set methods which will Get and Set Values to this variable. In a multithreaded application does it have any thread safety issues.

Class a {
static int b;
void Set (int c);
int Get();
};

View 10 Replies View Related

C++ :: Parsing String To Recognize Trigonometric Functions

Sep 14, 2014

How do I create a function that can understand trigonometric functions?

Examples:

if I am to input: x^2 + sin(x)

The program will understand the the value between parenthesis preceded by a string "sin" will be computed as the sine of x. of any function in case.

I have the program here.

#include <iostream>
#include <cstdlib>
#include <cctype>
#include <cstring>
using namespace std;
enum types { DELIMITER = 1, VARIABLE, NUMBER }; //DEL = 1; VAR = 2; NUM = 3.
class analyzer {

[Code] .....

View 9 Replies View Related

C++ :: Why If Statements Will Not Recognize Characters Inputted For Char

Oct 4, 2013

/*Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result.(For division, if the denominator is zero, output and appropriate message.) Some sample outputs follow:

3+4=7
13*5=65*/

#include <stdio.h>
int main()
{

[Code].....

View 10 Replies View Related

C++ :: How To Recognize Two Words Entered By User For A String

Feb 11, 2013

In my little experiment i am trying to get the compiler to recognize 1 word with 2 parts from a list of names.

For example: if the user wanted to choose "candy bar", from a list of items which include: "candy bar", "cat", "dog"

My current code can recognize words without a space like cat and dog. But how can i recognize candy bar?

I tried using getline but its of no use.

View 2 Replies View Related

C++ :: How To Make Protobuf Dependent Lib Available In Non-protobuf Environment

Jul 11, 2013

I have a C++ project depending on protobuf, but there's no guarantee that all users have protobuf installed on there own PC(protobuf is only not the only way of serialization) but they also want to use the project as a lib. In that case, dynamic linking to protobuf while compiling the project is not a choise(the project.so will dynamicly depending on libprotobuf.so) what can I do?

View 3 Replies View Related

C++ :: UDP Socket Library On Linux

Jan 29, 2014

I'm attempting to write a little UDP socket library in c++ on linux so a user can just create a new instance of a UDPSocket class, specify destination ip and port, and just connect. Then the user should be able to call send() or receive() in any order they want.. and here I encounter a little problem..

Most of the tutorials for udp socket sending out there include a bind() call when you create your "server" that is supposed to receive data, but the code that send data does not need one. Because I also want my library to support unicast/broadcast/multicast, I have read that I need to set the socket option SO_REUSEADDR on my sockets (since multiple sockets will need to be connected to same destination IP/port for broadcast/multicast)

My question is.. do I need to create 2 socket handles per "UDPSocke in order to make this work? One for sending and one for receiving data? In my code when I try to work with only 1 socket, it is only able to receive stuff from itself on unicast.. Or should I just remove the SO_REUSEADDR when in unicast mode, then try to bind with both sockets, accept that the bind will only work on the 1st socket, and take it from there?

View 1 Replies View Related

C :: Debugging A Code On Linux OS

Apr 11, 2013

I have a code that I'd like to debugg it.

Question
1 - What is the correct command line to use the debugger ?
2 - Do I need to install additional software for the debugger ?

if yes what it's name?

I use ububtu 12.4compiling command: gcc abc.c -lpthread -o abc

View 3 Replies View Related

C :: Creating Shell In Linux

Feb 22, 2015

This is what so far i did

Code:
#include <stdio.h>#include <string.h>
#include <ctype.h>
#include <bsd/string.h>

int
main(void)

[Code] ....

How to do this Using the fork(), execvp() and waitpid() system calls, launches the requested program and waits until the program has finished.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved