Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 991253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:04:47+00:00 2026-05-16T06:04:47+00:00

i am using a named pipe for IPC on a Debian system. I will

  • 0

i am using a named pipe for IPC on a Debian system. I will be sending some data as a set of strings from a bash script to a background running process written in C code.

The data i want to send is four strings eg accountid, firstname,surname, description. Currently i am sending the data as a char array separated by spaces from my bash script.

echo "accountid firstname surname description" >$pipe

In the background process i read the pipe data like this into char array ‘datain’

res = read(pipe_fd, datain, BUFFER_SIZE);

then i am just iterating over the array looking for spaces

eg

char* p = datain;

char accountid[80];
char firstname[80];

// extract the accountid
while(p!='')
{
    accountid = p;
    ++p;
}

++p;

while(p!='')
{
    firstname = p;
    ++p;
}

etc….

This method seems a bit crude however my programming skills are not that good so i was wondering if there was a better strategy for transferring this set of data over a named pipe in Linux.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:04:48+00:00Added an answer on May 16, 2026 at 6:04 am
    • A pipe (named or not) is a stream of bytes. If you were using the same language on both sides, there might be a better way of sending structured data. In your situation, a manual encoding and decoding, like you’re doing, is by far the easiest solution.

    • Don’t use spaces to separate fields that may contain spaces, such as people’s names. Use :, like /etc/passwd.

    • In C, read is hard to use, because you have to decide on a buffer size in advance and you have to call it in a loop because it may return less than the buffer size on a whim. The functions from stdio.h (that operate on a FILE* rather than a file descriptor) are easier to use but still require work to handle long lines. If you don’t care about portability outside Linux, use getline:

      FILE *pipe = fdopen(fd, "r");
      char *line = NULL;
      size_t line_length;
      getline(&line, &line_length, pipe);
      

    Then use strchr to locate the :s in the line. (Don’t be tempted to use strtok, it’s only suitable for whitespace-separated fields that can’t be empty.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 486k
  • Answers 486k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use the EXPLAIN PLAN statement to see what the dbms… May 16, 2026 at 8:09 am
  • Editorial Team
    Editorial Team added an answer Its a UAC/Permissions error; If your on vista/win7 right click… May 16, 2026 at 8:09 am
  • Editorial Team
    Editorial Team added an answer Don't micro optimize, make it readable. I think this is… May 16, 2026 at 8:09 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.