09-21-2008
I am not sure I understand. But you were right, if the above code is placed in the main() function, it works fine, but if I place it in a separate function and call this function from main(), it gives the garbage output.
But I am still not quite sure why it shouldn't work. As you said, first example works fine becuase dynamically allocated threadids exists beyond this fucntion, but it second example it dies immediately. So, shouldnt I face a problem when I place the code directly in the main() function ?? The threadids could die immediately again before the thread is actually spawned, in which case it picks up a garbage output.
Thanks.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is it possible to create a dynamic array in shell script. I am trying to get the list of logfiles that created that day and put it in a dynamic array. I am not sure about it. help me
New to scripting
Gundu (3 Replies)
Discussion started by: gundu
3 Replies
2. UNIX for Advanced & Expert Users
Hi,
Do anyone know what's the max size of array (in awk)
can be store before hit any memory issue.
Regards (3 Replies)
Discussion started by: epall
3 Replies
3. Shell Programming and Scripting
Could one of you, please, provide some input regarding my problem below and it is as follows:
I have 2 files that I need to make sure are identical before processing:
First, I sort both files
Second, I do a diff file1 file2 > File 3
This provides me with the difference.
Now, I need to... (6 Replies)
Discussion started by: ddedic
6 Replies
4. Shell Programming and Scripting
Gents,
Below is the Shell script which I am trying to hold a string of array that is passed from a java file. But it is not working . Can any one please help me to by fixing it.
#!/bin/csh/
set copy = ($argv)
echo $copy >> /home/users/bavananr/rrr.log
echo $copy >>... (3 Replies)
Discussion started by: brajesh
3 Replies
5. Shell Programming and Scripting
i want to create an array
the array elements are populated depending upon the number of entries present in a data file
The data file is created dynamically
how to achieve the same
thanks (1 Reply)
Discussion started by: trichyselva
1 Replies
6. Programming
Hi,
I have the following problem: i must allocate a dynamic array from a subroutine which should return such array to main function. The subroutine has already a return parameter so i thought of pass the array as I/O parameter. I tried the following program but it doesn't work (segmentation... (11 Replies)
Discussion started by: littleboyblu
11 Replies
7. Shell Programming and Scripting
Hi,
I'm just trying to use a dynamic index for some array elements that I'm accessing within a loop. Specifically, I want to access an array at variable position $counter and then also at location $counter + 1 and $counter + 2 (the second and third array positions after it) but I keep getting... (0 Replies)
Discussion started by: weak_code-fu
0 Replies
8. Programming
Hi everyone
I am developing an utility.
At some part of it I read directory entries to a dynamic array: struct list
It stores pointers to items: list.entries,
which are structures: struct entry
If a number of files in a directory is greater then number of elements an array was initially... (11 Replies)
Discussion started by: torbium
11 Replies
9. Programming
I put together a C function to add strings to a dynamic array of strings (mostly for educational purpose to explain pointers to my kid). It works, but sometimes one or two strings in the array becomes corrupted. Running example on 64 bit Ubuntu, gcc ver. 4.8.4
Hope my code is self-explanatory:
... (2 Replies)
Discussion started by: migurus
2 Replies
10. Shell Programming and Scripting
Arrays in dash, (POSIX).
Hi gurus...
I am thinking of trying AudioScope.sh in pure POSIX so...
I need an array in dash, I know it is not possible but pseudo-arrays are.
I have two versions that work, the second is an idea from the WWW.
The first is what I would like to use.
There are... (8 Replies)
Discussion started by: wisecracker
8 Replies
LEARN ABOUT LINUX
gen_udp
gen_udp(3erl) Erlang Module Definition gen_udp(3erl)
NAME
gen_udp - Interface to UDP sockets
DESCRIPTION
The gen_udp module provides functions for communicating with sockets using the UDP protocol.
DATA TYPES
ip_address()
see inet(3erl)
posix()
see inet(3erl)
socket()
as returned by open/1,2
EXPORTS
open(Port) -> {ok, Socket} | {error, Reason}
open(Port, Options) -> {ok, Socket} | {error, Reason}
Types Port = 0..65535
Options = [Opt]
Opt -- see below
Socket = socket()
Reason = posix()
Associates a UDP port number ( Port ) with the calling process.
The available options are:
list :
Received Packet is delivered as a list.
binary :
Received Packet is delivered as a binary.
{ip, ip_address()} :
If the host has several network interfaces, this option specifies which one to use.
{fd, int()} :
If a socket has somehow been opened without using gen_udp , use this option to pass the file descriptor for it.
inet6 :
Set up the socket for IPv6.
inet :
Set up the socket for IPv4.
Opt :
See inet:setopts/2 .
The returned socket Socket is used to send packets from this port with send/4 . When UDP packets arrive at the opened port, they are
delivered as messages:
{udp, Socket, IP, InPortNo, Packet}
Note that arriving UDP packets that are longer than the receive buffer option specifies, might be truncated without warning.
IP and InPortNo define the address from which Packet came. Packet is a list of bytes if the option list was specified. Packet is a
binary if the option binary was specified.
Default value for the receive buffer option is {recbuf, 8192} .
If Port == 0 , the underlying OS assigns a free UDP port, use inet:port/1 to retrieve it.
send(Socket, Address, Port, Packet) -> ok | {error, Reason}
Types Socket = socket()
Address = string() | atom() | ip_address()
Port = 0..65535
Packet = [char()] | binary()
Reason = not_owner | posix()
Sends a packet to the specified address and port. The Address argument can be either a hostname, or an IP address.
recv(Socket, Length) -> {ok, {Address, Port, Packet}} | {error, Reason}
recv(Socket, Length, Timeout) -> {ok, {Address, Port, Packet}} | {error, Reason}
Types Socket = socket()
Length = int()
Address = ip_address()
Port = 0..65535
Packet = [char()] | binary()
Timeout = int() | infinity
Reason = not_owner | posix()
This function receives a packet from a socket in passive mode.
The optional Timeout parameter specifies a timeout in milliseconds. The default value is infinity .
controlling_process(Socket, Pid) -> ok
Types Socket = socket()
Pid = pid()
Assigns a new controlling process Pid to Socket . The controlling process is the process which receives messages from the socket.
close(Socket) -> ok | {error, Reason}
Types Socket = socket()
Reason = not_owner | posix()
Closes a UDP socket.
Ericsson AB kernel 2.14.3 gen_udp(3erl)