Hello. I have to write a pipe to joint a GUI in perl and a simulation
program in c. I have read all the docs found in perl.com and now I am
trying to make a test with this simple program if it is working I will
use it for the rest of the prgram. It seems working but it
does not write "bonjour" at the end. Can anybody tell me where my
mistake is? I will be happy for any sample of code for a pipe between c
and perl sent to me too.
Thanks in advance,
Ignazio
#include <stdio.h>
#include <memory.h>
#include <unistd.h>
char chaine[7];
int status;
int main( int argc, char ** argv )
{
/* create the pipe */
int pfd[2];
int pid;
if ((pid = fork()) < 0)
{
printf("fork failed\n");
return 2;
}
if (pid == 0)
{
/* child */
close(pfd[0]);
write(pfd[1],"bonjour",7 );
dup2(pfd[1], 1); /* connect the write side with stdout */
close(pfd[1]); /* close the write side */
printf("CHAINE FILS %s\n",chaine);
//return 3;
exit(0);
}
else
{
/* parent */
close(pfd[1]); /* close the unused write side */
dup2(pfd[0], 0); /* connect the read side with stdin */
read (pfd[0],chaine,7);
close(pfd[0]); /* close the read side */
printf("CHAINE PARENT %s\n",chaine);
wait(&status);
}
} 2 3671
In article <11************ **********@51g2 000cwl.googlegr oups.com>,
Igna <ig*******@gmai l.comwrote:
>Hello. I have to write a pipe to joint a GUI in perl and a simulation program in c.
Pipes and GUIs and perl cannot be done in standard C.
Try comp.unix.progr ammer for your questions. (But first, read the
replies from when you posted the question the first time.)
--
Programming is what happens while you're busy making other plans.
Hello Ignazio,
Hello. I have to write a pipe to joint a GUI in perl and a simulation
program in c. I have read all the docs found in perl.com and now I am
trying to make a test with this simple program if it is working I will
use it for the rest of the prgram. It seems working but it
does not write "bonjour" at the end. Can anybody tell me where my
mistake is? I will be happy for any sample of code for a pipe between c
and perl sent to me too.
This is outside of topic for a NG like comp.lang.c.
comp.unix.progr ammer would be more appropriate. Anyway, I am missing
the pipe creation in your code.
HTH,
Loic.
#include <stdio.h>
#include <memory.h>
#include <unistd.h>
char chaine[7];
int status;
int main( int argc, char ** argv )
{
/* create the pipe */
int pfd[2];
add here:
if ( pipe(pfd)==-1) {
printf("pipe failed\n");
return 2;
}
>
int pid;
if ((pid = fork()) < 0)
{
printf("fork failed\n");
return 2;
}
if (pid == 0)
{
/* child */
close(pfd[0]);
write(pfd[1],"bonjour",7 );
dup2(pfd[1], 1); /* connect the write side with stdout */
close(pfd[1]); /* close the write side */
printf("CHAINE FILS %s\n",chaine);
//return 3;
exit(0);
}
else
{
/* parent */
close(pfd[1]); /* close the unused write side */
dup2(pfd[0], 0); /* connect the read side with stdin */
read (pfd[0],chaine,7);
close(pfd[0]); /* close the read side */
printf("CHAINE PARENT %s\n",chaine);
wait(&status);
}
}
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bernhard Kuemel |
last post by:
Hi!
I want to read/write commands and program input to/from /bin/bash
several times before I close the stdin pipe. However, reading
from cat hangs unless I first close the stdin pipe.
<?php
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child
|
by: jenny |
last post by:
Hi,
I have a java socket program running on AIX 4.3.3.0 platform. It
opens a socket and sends data to our customer over a leased fractional
T1 line. The line is always connected. However, periodically, I see
"java.IO.Exception: There is no process to read data written to a
pipe" error message in my log file. Can anybody tell me in what cases
this error message could occur?
The other strange thing is that our customer would report...
|
by: richard |
last post by:
I have a simple test to pass information from a client to a server
using named pipe. what I really want is: when I type a line on the client,
the server will output the line immediately. but to my surprise, I always
have to terminate the client to get the server in action, i.e. prints out
what I typed.
anything I missed? I am compiling using gcc without any option.
thanks,
---RICH
|
by: Huey |
last post by:
Hi All,
I encountered a funny thing, and my code schetch as below:
#define READ 0
#define WRITE 1
int byteRead, status, pd;
char buff;
|
by: Greg |
last post by:
I am trying to implement the UNIX pipe command using C but with the
"->" operator. Everything works fine with 1 pipe, but when I try to
use 2 or more, it hangs up when reading the pipe_in filestream. If
ANYONE could offer ANY suggestion as to why this is happening it would
be much appreciated.
Thanks in advance!
| |
by: FB's .NET Dev PC |
last post by:
I am writing two services in VB.NET, one of which needs to send text strings
to the other. After reading, I
decided (perhaps incorrectly) that named pipes would be the best
interprocess communication method
for this task.
I set about creating, on the pipe's server side, a new thread which would
instantiate a blocking inbound message pipe, and the
client side which would write to that pipe when needed. Being on the same
PC, security is...
|
by: scottyman |
last post by:
I can't make this script work properly. I've gone as far as I can with
it and the rest is out of my ability. I can do some html editing but
I'm lost in the Java world. The script at the bottom of the html page
controls the form fields that are required. It doesn't function like
it's supposed to and I can leave all the fields blank and it still
submits the form. Also I can't get it to transfer the file in the
upload section. The file name...
|
by: Jeremy Sanders |
last post by:
Hi - I have some code which works under linux. It starts a remote python
process using subprocess and communicates to it via a pipe created by
os.pipe. As far as I understand, child processes should inherit file
descriptors from the parent if close_fds=False on the suprocess.Popen
command line.
This code doesn't work under Window, but gives "bad file descriptor" when
trying to read from the pipe in the child process. I have some example...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |