Sponsored Content
Top Forums Programming How to make a C code reentrant? Post 8211 by rwb1959 on Monday 8th of October 2001 11:17:16 AM
Old 10-08-2001
Did you write the code?
Was it written for and compiled on UNIX/Linux?
Does the code interact with any devices or shared resources?

In general (based on your question alone), you can run a
"black box" type of process any number of times from any
number of termials. Much depends on what it is the code
needs to do.
The basics for writing reentrant functions is
a reentrant function does not hold static data over successive
calls, nor does it return a pointer to static data. All data is
provided by the caller of the function. A reentrant function must
not call non-reentrant functions.
In most cases, non-reentrant functions must be replaced by
functions with a modified interface to be reentrant. Non-reentrant
functions cannot be used by multiple threads. Furthermore, it may
be impossible to make a non-reentrant function thread-safe.

You may want to pick up a book or two on advanced unix
programming and programming threads for a more in-depth
discussion on reentrant and thread-safe code.
 

9 More Discussions You Might Find Interesting

1. Linux

Need direction to make code for cellphone in C,C++ or Perl

Hi All, I need a help from the techie guys in this group.Actually, i need to make a code which can make wallpaper and ringtone for a mobile phone using any method. I know C,C++ and perl langauges but doesnot having much knowledge of JAVA. So can anybody tell me that whether i can... (0 Replies)
Discussion started by: basileis
0 Replies

2. Shell Programming and Scripting

Please make this code elegant.

Hi All, Following is the part of my script.It does contain many for loops and is not elegant. Please feel free to suggest any changes to make this elegant. Thanks! nua7 for i in `ls $CATALINA_HOME/shared/lib/*.jar`; do LOCALCLASSPATH="$LOCALCLASSPATH:$i" done for i in... (3 Replies)
Discussion started by: nua7
3 Replies

3. UNIX for Advanced & Expert Users

how to port a package to huge source code having its own make and compilers

In general for intalling a package like we do ./configure, make , make install But if we want to integrate the package with a huge source base what are the things to be taken care could some one have a light on purpose of ./configure , make and make install along with above question. I... (1 Reply)
Discussion started by: Gopi Krishna P
1 Replies

4. Solaris

Gani Network Driver Won't Install - make: Fatal error: Don't know how to make targ...

I attached a README file that I will refer to. I successfully completed everything in the README file until step 4. # pwd /gani/gani-2.4.4 # ls COPYING Makefile.macros gem.c Makefile Makefile.sparc_gcc gem.h Makefile.amd64_gcc ... (1 Reply)
Discussion started by: Bradj47
1 Replies

5. Shell Programming and Scripting

trying to make an AWK code for ordering numbers in a column from least to highest

Hi all, I have a large column of numbers like 5.6789 2.4578 9.4678 13.5673 1.6589 ..... I am trying to make an awk code so that awk can easily go through the column and arrange the numbers from least to highest like 1.6589 2.4578 5.6789 ....... can anybody suggest, how can I do... (5 Replies)
Discussion started by: ananyob
5 Replies

6. UNIX for Advanced & Expert Users

How to Make Sql Plus Exit with an Error Code

Dear all, How to make sqlplus command to exit with an apt error code in bash script, It always returns 0 for me. Thanks (9 Replies)
Discussion started by: vetrivendhan
9 Replies

7. Programming

Help with make this Fortran code more efficient (in HPC manner)

Hi there, I had run into some fortran code to modify. Obviously, it was written without thinking of high performance computing and not parallelized... Now I would like to make the code "on track" and parallel. After a whole afternoon thinking, I still cannot find where to start. Can any one... (3 Replies)
Discussion started by: P_E_M_Lee
3 Replies

8. Shell Programming and Scripting

Code to make sure Script runs only on sunday -

Hi I have written a script which restarts the application , I want to add a piece of code in my script , to make sure this gets executed only on sunday . So that even if someone runs it on any other day by mistake it should exit throwing an error message . Can someone please assist what will... (6 Replies)
Discussion started by: honey26
6 Replies

9. Shell Programming and Scripting

How to make this code working?

Hi Gurus, I wrote a simple code, but it doesn't work, can body help me to fix the issue. awk -F',' 'BEGIN{n=0}{ NR == FNR {fname;next} { if ($3==fname) n=1 } END{if n==0} }' tmpsrc srcfile.txt Thanks in advance (4 Replies)
Discussion started by: ken6503
4 Replies
getprotoent(3N) 														   getprotoent(3N)

NAME
getprotoent(), getprotobynumber(), getprotobyname(), setprotoent(), endprotoent() - get, set, or end protocol entry SYNOPSIS
_XOPEN_SOURCE_EXTENDED only DESCRIPTION
The and functions each return a pointer to a structure of type protoent containing the broken-out fields of a line in the network protocol data base, The members of this structure are: The official name of the protocol. A null-terminated list of alternate names for the protocol. The protocol number. Functions behave as follows: Reads the next line of the file, opening the file if necessary. Opens and rewinds the file. If the stayopen flag is non-zero, the protocol data base is not closed after each call to (either directly or indirectly through one of the other calls). Closes the file. Each sequentially searches from the beginning of the file until a matching protocol name (among either the official names or the aliases) or protocol number is found, or until EOF is encountered. In a multithreaded application, and use thread-specific storage that is re-used in each call. The return value should be unique for each thread and should be saved, if desired, before the thread makes the next call. For enumeration in multithreaded applications, the position within the enumeration is a process-wide property shared by all threads. may be used in a multithreaded application, but resets the enumeration position for all threads. enumerates protocol entries: successive calls to will return either successive protocol entries or NULL. If multiple threads interleave calls to the threads will enumerate disjoint subsets of the protocol database. If the system is running the Network Information Service (NIS), and get the protocol information from the NIS server (see ypserv(1M) and ypfiles(4)). Name Service Switch-Based Operation The library routines and their reentrant counterparts, internally call the name service switch to access the "protocols" database lookup policy configured in the file (see nsswitch.conf(4)). The lookup policy defines the order and the criteria of the supported name services used to resolve protocol names and numbers. RETURN VALUE
and return a null pointer(0) on EOF or when they are unable to open OBSOLESCENT INTERFACES
The above reentrant interfaces have been moved from to They are included to support existing applications and may be removed in a future release. New multithreaded applications should use the regular APIs without The reentrant interfaces performs the same operation as their regular counterpart (those without the suffix.) However, and expect to be passed the address of a parameter and will store the address of the result at this supplied parameter. An additional parameter, an address to struct protoent_data, which is defined in the file cannot be a NULL pointer. The reentrant routines return if the operation is unsuccessful, or, in the case of if the end of the services list has been reached. is returned otherwise. EXAMPLES
The following code excerpt counts the number of protocols entries: WARNINGS
Programs that use the interfaces described in this manpage cannot be linked statically because the implementations of these functions employ dynamic loading and linking of shared objects at run time. AUTHOR
was developed by Sun Microsystems Inc. FILES
SEE ALSO
ypserv(1M), nsswitch.conf(4), protocols(4), ypfiles(4), thread_safety(5). STANDARDS CONFORMANCE
getprotoent(3N)
All times are GMT -4. The time now is 05:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy