C :: Linux IPC Implement Signal And Slot For New Message

Dec 4, 2014

I'm new in IPC. I would like to implement a signal of a new message, which calls the slot function, eg .:

Code:
msg_on_newMessange(type, &slotFunction);

My code:
Header file: messages.h
Parent file: parent.c
Child file: child.c

How can I do this ?

View 2 Replies


ADVERTISEMENT

C++ :: How To Only Take Partial Data From Vector Slot

Apr 25, 2013

Suppose I have this vector it contains dates example

Vector.Dates [slot 1][slot 2] [slot 3] etc...

anyways slot 1 contains [ 05282013]
slot 2 contains [07032015]

I want to split the data it contains into 3 other locations How do I do that???

like vector.1[05][07]
vector.2 [28][03]
vector.3[2013][2015]

How do you only take partial data from a vector slot?

View 1 Replies View Related

C :: Signal Function Defined Twice With No Error?

Dec 13, 2013

I'm using a library in my code in a file called "my_signal.c". In this file I've defined this function:

Code:
Sigfunc * signal(int signo, Sigfunc *func){
struct sigaction act, oact;
...
}

Since the signal function is also in file signal.h and I included it in "my_sygnal.h" file, I'm wondering why the compiler did not say anything about this "double declaration" of the function with the same name.

View 9 Replies View Related

C :: How To Signal End Of Standard Input Using Scanf

Oct 30, 2013

so i'm using scanf() this way

Code:

int i;
while (scanf("%i", &i))
printf("%i ", i);
printf("
done
");

i tried several combination of Ctrl+D and "Enter", it's not terminating, Ctrl+C just "cancels" the whole thing without printing "done", i'm running this on linux installed on a PC

View 9 Replies View Related

C++ :: Signal Or Array Or Vector Shifting?

Dec 6, 2013

This can be done very easy, but I assume there is a better way to do it.

assume that I have a vector or a signal like

x=[1 1 1 1 1]

want to shift it by one unit to the right I have

x[n+1] gives

xn=[0 1 1 1 1 1]

and x[n-1] vies

xn=[1 1 1 1 0]

as you can see the length of the original vector or array does not change.

How can I solve this problem without specify the length of the output vector. The size of the output array should be the same as the input array, but I couldn't find a way to do it without adjusting the size.

View 2 Replies View Related

C :: Program Received Signal - Segmentation Fault

Sep 29, 2014

gdb result is

Code:
Program received signal SIGSEGV, Segmentation fault.
isoc99_fscanf (stream=0x0, format=0x4014e0 "%u %u %u %u")
at isoc99_fscanf.c:30
30 isoc99_fscanf.c: No such file or directory. Code:

[Code].....

View 2 Replies View Related

C :: Program To Execute Foreground Process - Signal Handling

Feb 3, 2014

I am trying to create a program that would execute a foreground process. I have this code for the foreground process

Code:
#include <stdio.h>
#include <signal.h>
int main() {
int temp;
printf("We are in the current program

[Code] ....

And this is my main program

Code:
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
int main() {
signal(SIGINT, SIG_IGN);

[Code] ....

My main program stops executing after the process "./scanf" executes and there fore does not print the line "How are You"...

I want to main program to continue executing after "./scanf" finishes. How to achieve that?

View 2 Replies View Related

C/C++ :: Setting Signal Handler - How To Access Class Member

Dec 4, 2014

I need to set signal handler for my process. As the signal is related with the process on system level I have faced the problem. My program consists several classes. They are connected together. But it doesn't metter in this case. The problem is that I need to access to member and methods of the class from my signal handler. For instance , I have class named Foo at it has some members and methods.

So from my handler I need to call its function and change members. I understand that compiler should know that this class instances will exist during all program execution. I have tried to set static member class Foo instance in another class , but this didn't solve the problem. How to correctly implement signal handling in such case.

Here is example of my code

class MyContainer {
private:
std::vector<Foo> container;
public:
int removeFromContainer(Foo* aFoo) {

[Code] ....

View 1 Replies View Related

C++ :: How To Access Class Member And Methods From Static Method (signal Handler)

Dec 4, 2014

I am writing my program on C++ language. I have one promblem. I need to set signal handler for my process. As the signal is related with the process on system level I have faced the problem.

My program consists several classes. They are connected together. But it doesn't metter in this case. The problem is that I need to access to member and methods of the class from my signal handler. For instance , I have class named Foo at it has some members and methods.

So from my handler I need to call its function and change members.

I understand that compiler should know that this class instances will exist during all program execution.

I have tried to set static member class Foo instance in another class , but this didn't solve the problem.

What is correct approach to do this. How to correctly implement signal handling in such case.

Here is example of my code

Code:
class MyContainer{
private:
std::vector<Foo> container;
public:
int removeFromContainer(Foo* aFoo) {

[Code] .....

View 4 Replies View Related

C/C++ :: Send Signal SEGV To Crash A Running Process In Windows To Dump Core

Jul 2, 2014

I need to do an equivalent of kill -11 <pid>(which is in unix) in windows.

I need to crash a process with SEGV so that it would dump core in windows. Is there any tool by which we can do this . Also is there any sample code through which we can achieve this .

In windows we have taskill which only terminates a process , but is unable to send a signal like SEGV to the process upon which it would terminate and dump core .

View 9 Replies View Related

C++ :: Errors With Unresolved Token And Unresolved External Signal

Jul 10, 2013

My program will not run because of error LNK2028 "unresolved token" and error LNK2019 "unresolved external signal" and I do not know why. My teacher says that I need to make the constructor and display functions display class variables in different formats, but I do not know what to do with that. Here are my 3 files:

Header take 2.h:

#pragma once
#include <iostream>
#include <string>
using namespace std;
class Heading {
private:
string company, report;

[Code] ....

Here are the errors:
Error1error LNK2028: unresolved token (0A0003C9) "public: __thiscall Heading::Heading(void)" (??0Heading@@$$FQAE@XZ) referenced in function "int __cdecl main(void)" (?main@@$$HYAHXZ)c:UsersOwnerdocumentsvisual studio 2012ProjectsClassLibrary2ClassLibrary2Source1.objClassLibrary2

[Code] ....

View 2 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

C :: Implementing GUI On Linux Platform

Jul 6, 2014

I am an experience C programmer but never implement GUI.

I need to make a demo implementation that will be run on Linux and will implement GUI.

I searched the WEB and found lot of information, among is implementing the GUI in HTML and run the API through web browser.

How can I make such implementation in C?

View 2 Replies View Related

C :: Compiling 2 Files In Linux Gcc

Sep 22, 2014

I want to use two separate files in 1 program, but cannot get it to work. I don't know if it's my files or the compiling thats wrong. I have never used 2 files in my programs so far. Only used #include <stdio.h>.

Here are my files:
extern_static.c Code: extern int i;
int main(void)
{

[Code]....

View 10 Replies View Related

C :: File Which Can Be Compiled In Linux Via GCC

Aug 16, 2013

I have a c file which can be compiled in Linux via GCC , but when I compile it in NetBeans via Cygwin or MinGW , it doesn't work and keeps throwing a segmentation fault.

View 14 Replies View Related

C++ :: Works On Solaris But Not On Linux?

Apr 24, 2013

I have this following piece of code:

int id = 5;
const char *ptrId;
ptrId = ( int_to_str(id) ).getPtr(); // Works in Solaris well

But the above code prints some junk values when I run the same on Linux machine. But the following works well on Linux:

String temp = int_to_str(id);
ptrId = temp.getPtr();

The prototype of getPtr() is:
const char* String::getPtr() const

View 2 Replies View Related

C/C++ :: Linux Console Get Key State

Jan 23, 2014

I want to create command line game in Linux but I don't know to get the key state. I heard of getch() but that stops the program.

View 1 Replies View Related

C/C++ :: Opening Application From Another Linux Mac

Dec 15, 2014

I want to open an application A from another application B. By opening it, I don't want to open it within B. I found many ways to call an application from within another. However, what I want to do is open the other one(A) simultaneously. How can I achieve this? fork() and exec() seem to open A within B. I am developing a code for Linux and Mac.

View 7 Replies View Related

C++ :: Why Using Namespace Required In Linux But Not In Turbo

Jan 8, 2015

Why is using namespace needed in linux but not in turbo c++?

View 1 Replies View Related

C/C++ :: MD5 Checksum Mismatching On Windows And Linux?

Feb 17, 2014

I have implemented MD5 checksum algorithm by using C language, but it is resulting correct value in windows but not in Linux?

// Constants are the integer part of the sines of integers (in radians) * 2^32.
const uint32_t k[64] = {
0xd76aa478, 0xe8c7b756, 0x242070db, 0xc1bdceee ,
0xf57c0faf, 0x4787c62a, 0xa8304613, 0xfd469501 ,
0x698098d8, 0x8b44f7af, 0xffff5bb1, 0x895cd7be ,
0x6b901122, 0xfd987193, 0xa679438e, 0x49b40821 ,

[Code] .....

View 2 Replies View Related

C++ :: Detect Arrow Key Press For Linux Only

May 13, 2012

I'm trying to implement this on ubuntu, to compile and run only under ubuntu.

I found 100s of other attempts at answering the general question of arrow key press in c++. Nothing solid.

Some recommend using the Readline for the functionality I am trying to implement, but I need to stay clear of GNU licences if I can for this project. And some tips only work on projects for windows machines... for example the conio library.

For linux there may be the option of using the ncurses library which I will take a look at, but I am stubborn and want to implement this myself. It should be an easy straight forward thing to do, which is why I am a bit frustrated at the moment.

Here is my test code so far.

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;

[Code] ....

So! This works... 80% of the problem is solved. If you compile this, g++ under linux, ubuntu in my case, and run. Each keystroke reveals the correct key numbers.

q=113
w=119

when I click on the up key I get,

up = 279165

I thought, I can use this number is a if(int == '279165') to detect the up key.

I was not so lucky... this int is not behaving like an int!

So I modified the code to see it I could carry out an int operation on this number.

I added a 100000 to int i.

cout<< i + 100000;

Code:
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
using namespace std;
int main(void) {
char a;
stringstream ss;
string s;

[Code] .....

Compiling and running this, and pressing the UP key gives the following number.

100027100091100065

Some some sort of array, something like, [27][91][65].

I tried all ways to access these individual numbers, actually the third one for comparison purposes, but no luck.

For completeness sake I list the other arrows.

UP = [27][91][65]
DOWN = [27][91][66]
LEFT = [27][91][68]
RIGHT = [27][91][67]

A little further digging shows that these numbers are derived from the representation of a "multi-char" constant, the data type given when pressing special characters...

Now here is the main problem I have, I can find ANY decent documentation on how to handle and play with "multi-char" .

View 4 Replies View Related

C :: Build A Linux Process Scheduler From Scratch

Apr 5, 2013

I'm trying to build a Linux Process Scheduler from scratch but dont know where to start.

View 1 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++ :: Detecting Any Key Of Keyboard And Mouse On Windows / Linux?

Jun 20, 2014

I am trying to detect keys pressed on a keyboard and mouse on both, Windows and Linux but I am unsure what would be the best practice way to do so. Will I have to detect the keys for each platform individually? Would you make use of an event listener? What's the best way to detect the input-devices?

View 1 Replies View Related







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