The code you posted has a problem. But even if you solve that problem, there is another one. fork() dup()licates fd's from the parent but if you don't have some kind of synchronous read between the childs, you'll have unexpected results.
Do you really want to use multiple processes to read the same fd?
Try running this several times to see what I'm talking about:
Ok, I'm sure this is a total newbie question, but I think I'm in the right place, no?
I'm trying to call a perl module from a cgi script - Mail::Sendmail - and my web host installed the module in a directory that doesn't seem to be accessible, at least not the way I'm trying. But I thought you... (1 Reply)
I am trying to find a way to check the current status of a file. Such as some cron job processes are dependent on the completion of others. if a file is currently being accessed / modified or simply open state I will wait until it is done being processed before attempting the next process on that... (3 Replies)
Im working on writing a small operating system. I am currently working on implementing dup, dup2, pipe, and close and I need to implement some type of file descriptor table in my PCB.
I was wondering if there is anyone who is familiar with linux/unix implementation of these tables who could... (6 Replies)
Hello All,
Im opening a file desciptor in perl and sending data using print CMD "$xyz".
is there a limit to the length of the string that I can give to this CMD at a time. (3 Replies)
Hello,
How can i use file descriptor in a script to read 2 files at the same time and extract line 200 from file 1 and line 500 from file 2.
Thanks. (6 Replies)
Hello guys!
I had seen some posts at this forum talking about my problem, but maybe my scenario is a little different, and I want other solutions.
I saw users of this forums saying that the way to shared sockets is using UNIX Sockets, but this is the only way in my scenario?
My Scenario:... (4 Replies)
I am trying to write a script which will only show me the file descriptor count for a process/pid. My script will return me the count only not the whole output. For example, I would like my script to return the output 23 this case, not the whole output.
Can anybody please help me how do I get... (11 Replies)
Hi,
I am trying to read a file line-by-line in a while loop, and perform some tasks which involves non-interactive SSH to a remote server. The code looks something like this --
#!/usr/bin/ksh
export myFile=/path/to/my/file.load
while read line
do
do something
## Adding the SSH... (2 Replies)
Discussion started by: Subu1987
2 Replies
LEARN ABOUT DEBIAN
gsm_create
GSM(3) Library Functions Manual GSM(3)NAME
gsm_create, gsm_destroy, gsm_encode, gsm_decode -- GSM 06.10 lossy sound compression
SYNOPSIS
#include "gsm.h"
gsm gsm_create();
void gsm_encode(handle, src, dst)
gsm handle;
gsm_signal src[160];
gsm_frame dst;
int gsm_decode(handle, src, dst)
gsm handle;
gsm_frame src;
gsm_signal dst[160];
void gsm_destroy(handle)
gsm handle;
DESCRIPTION
Gsm is an implementation of the final draft GSM 06.10 standard for full-rate speech transcoding.
gsm_create() initializes a gsm pass and returns a 'gsm' object which can be used as a handle in subsequent calls to gsm_decode(),
gsm_encode() or gsm_destroy().
gsm_encode() encodes an array of 160 13-bit samples (given as gsm_signal's, signed integral values of at least 16 bits) into a gsm_frame of
33 bytes. (gsm_frame is a type defined as an array of 33 gsm_bytes in gsm.h.)
gsm_decode() decodes a gsm_frame into an array of 160 13-bit samples (given as gsm_signals), which sound rather like what you handed to
gsm_encode() on the other side of the wire.
gsm_destroy() finishes a gsm pass and frees all storage associated with it.
Sample format
The following scaling is assumed for input to the algorithm:
0 1 11 12
S..v..v..v..v..v..v..v..v..v..v..v..v..*..*..*
Only the top 13 bits are used as a signed input value.
The output of gsm_decode() has the three lower bits set to zero.
RETURN VALUE
gsm_create() returns an opaque handle object of type gsm, or 0 on error. gsm_decode() returns -1 if the passed frame is invalid, else 0.
EXAMPLE
#include "gsm.h"
gsm handle;
gsm_frame buf;
gsm_signal sample[160];
int cc, soundfd;
play() { /* read compressed data from standard input, write to soundfd */
if (!(handle = gsm_create())) error...
while (cc = read(0, (char *)buf, sizeof buf)) {
if (cc != sizeof buf) error...
if (gsm_decode(handle, buf, sample) < 0) error...
if (write(soundfd, sample, sizeof sample) != sizeof sample)
error...
}
gsm_destroy(handle);
}
record() { /* read from soundfd, write compressed to standard output */
if (!(handle = gsm_create())) error...
while (cc = read(soundfd, sample, sizeof sample)) {
if (cc != sizeof sample) error...
gsm_encode(handle, sample, buf);
if (write(1, (char *)buf, sizeof buf) != sizeof sample)
error...
}
gsm_destroy(handle);
}
BUGS
Please direct bug reports to jutta@cs.tu-berlin.de and cabo@cs.tu-berlin.de.
SEE ALSO toast(1), gsm_print(3), gsm_explode(3), gsm_option(3)GSM(3)