Multithreaded Programming on Solaris

Hi,
I'd like to ask a question regarding multithreaded programming using C/C++ on Solaris. I wanna write a program that can fork a child process to execute a command line call. How can the parent process terminate the child process if the child process cannot complete in a reasonable amount of time? Any help would be greatly appreciated. Thank you.

Set an alarm timer in the parent process. Waitid for the child to complete.
- If the child completes, cancel the timer with alarm(0).
- If the timer pops, issue a kill -15/9 to the child process, then waitid to clean up the zombie. You can check for EINTR returned from your waitid and kill the child then if you don't want to do it in the interrupt handler.
Dave

Similar Messages

  • Multithreaded Programming in Solaris

    Hi,
    I'd like to ask a question regarding multithreaded programming using C/C++ on Solaris. I wanna write a program that can fork a child process to execute a command line call. How can the parent process terminate the child process if the child process cannot complete in a reasonable amount of time? Any help would be greatly appreciated. Thank you.

    more multiprocess than multithreaded..
    use fork1() to get a new process, but the parent gets the pid of the child as the return of fork1().
    The parent needs to then wait()/waitpid() for the child to exit so it can reap the status and not leave zombies around.
    Prior to blocking in wait/waitpid you can use alarm() to get a signal delivered after n seconds. That will interrupt the wait/waitpid, whose return code and errno can be checked to see if the wait was interrupted. If it was interrupted you can kill the child with kill() if not the alarm can be cancelled with alarm(0).
    Whilst you wait/waitpig the child process can then exec() the program you want it to run or the child could call system()
    For advanced usage you can get the child to put itself into a new process group so that kill can get the child and all its children..
    tim

  • Multithreading issue on Solaris 8 branded zone

    Hi,
    We are facing a multithreading problem in Solaris 8 container (branded zone) on Solaris 10.
    The core file shows 2 LWPs for a single thread.
    First LWP
    (dbx) lwp
    current LWP ($lwp) is l@1403
    (dbx) print this->m_ThreadId->m_IdImpl.m_PosixId
    this->m_ThreadId.m_IdImpl.m_PosixId = 1404U
    Second LWP
    (dbx) lwp
    current LWP ($lwp) is l@1404
    (dbx) print this->m_ThreadId->m_IdImpl.m_PosixId
    this->m_ThreadId.m_IdImpl.m_PosixId = 1404U
    Another point to note is that dbx returns 'MT support is disabled' for this program even though it has been built using the -mt option. The dbx version is Sun Dbx Debugger 7.5 2005/10/13.
    As far as I have read, the Solaris 8 branded zone uses the alternate T2 thread library. Note also that this program is linked with the alternate thread library @ /usr/lib/lwp.
    This alternate thread library is supposed to use the 1:1 thread model.
    Can someone explain why are we then seeing 2 LWPs for a single thread ?
    Thanks,
    Best regards,
    Raj Iyer

    This error messages are output by
    cssd which is a input method of Japanese.
    If you don't use Japanese input method cs00, you can stop it by following method.
    # /etc/init.d/loc.ja.cssd stop
    # mv /etc/rc2.d/S90loc.ja.cssd /etc/rc2.d/_S90loc.ja.cssd

  • How to run the w120p.rex program in Solaris

    Hi,
    I'm new to Solaris, i want to run one .rex program from solaris. My program w120p.rex which is working fine in windows. I want to run the same from the Solaris. I dont know how to do in Solaris. Can any one help me in this?
    Thanks in advance....

    This forum is about Sun Studio C compiler and C programming in general. I suggest you ask on one of OpenSolaris forums - http://www.opensolaris.org/jive/index.jspa?categoryID=1
    If I get it right and you are looking for Rexx interpreter, you'll need to download and install it first. Here are first two links I found myself:
    http://nixbit.com/cat/programming/interpreters/regina-rexx-interpreter/
    http://users.comlab.ox.ac.uk/ian.collier/Rexx/rexximc.html
    If you are new to Unix in general, there are several subjects you need to cover before you proceed; one of places to start is again a Solaris forum - http://forums.sun.com/forum.jspa?forumID=863

  • How to invoke browser from java program in Solaris ?

    Hi all,
    Is there any way by which a browser can be opened with specific URL, from a java program in solaris OS ?
    In windows I am able to do so by using "rundll32 url.dll,FileProtocolHandler".
    Thanks,
    ngs

    Well, how is a browser normally invoked on Solaris? And have a look at JDIC, maybe it helps you.

  • Multimedia programs for Solaris 10

    Hi All,
    I am looking some multimedia programs like mp3 players, avi players, jpg viewers.
    I have found some but installing it (for example vlc) is very difficult.
    Maybe you know some web page where I can find more programs for Solaris.
    Kind regards,
    Daniel

    good luck.
    Real player is now included automagically. It covers most of what you can do. There are some oss types out there that allow a little more coverage but not much.
    XMMS is the only really decent jukebox I have found and I believe it works quite well for mp3s.
    I am sure others have some better advice. Blastwave is where I get xmms.

  • Multithread program with socket, help me

    Hi all, I have had some troubles with my multithread program, that is when I make 4 threads to send messages to 4 accepted ports: 2001, 2002, 2003 and 2004, it leads to the error:
    "Java.net.SocketException: Software caused connection abort: recv fail"
    I cannot understand why this exception is inconsistent. Please help me figure out
    solution for this problem. Thank you.
    Here is my code
    public synchronized void sendREQMessage(Message obj)
         for(int i=2001;i<=2004;i++)
              try
                             obj.setPortDest(i);
                             myThread thread=new myThread(obj,i);
                   catch (Exception e)
                        System.out.println(e);
    public myThread(Message obj,int i)
              message=obj;
              port=i;
              start();
         public void run()
              try
                   message.setPortDest(port);
                   connection = new Socket("127.0.0.1",port);
                   out = new ObjectOutputStream(
         connection.getOutputStream());               
                   out.writeObject(message);
                   out.flush();
                   //connection.close();
              catch(Exception e)
                   System.out.println(e);
         }

    I'm sorry, I cannot understand what you mean.
    Sometimes, the message can be sent well among 4 ports. Sometimes, it leads to the error:
    "Java.net.SocketException: Software caused connection abort: recv fail"
    And I don't know why.
    Thank for your help

  • PPPoe Keep-Alive Program for Solaris 8?

    Is there a PPPoE Keep-alive program for Solaris 8? I need this because my DSL provider keeps knocking me off and therefore I lose my connection. I would prefer the program be precompiled if there is one available.
    -Thanks in advance

    It sounds like you are accidentally running NIS. Somewhere, you told your system that "mydomain.net" was your NIS domain. Look to see if you have an /etc/defaultdomain file. Remove it. You don't have NIS, and you probably have the wrong /etc/nsswitch.conf setup then, too.
    Try copying /etc/nsswitch.dns /etc/nsswitch.conf (make a backup first).
    Verify that you have 'nameserver' entries in /etc/resolv.conf and a 'domain mydomain.net' entry at the very beginning. This is where you let the system know your Internet domain (well, also in the fully-qualified domain name of your machine in your /etc/hosts file).
    In your /etc/hosts file, the first name of your machine should be the FQDN, then a short alias, if you are going to use one, and probably "loghost". You might put "loghost" as an alias for "localhost".
    Make sure your 'hostname' reflects the FQDN, or mail might not like it. Try setting the hostname with 'uname -S <hostname>' if it isn't correct.
    Good luck.

  • Understanding java multithread programming

    Hi
    I am new to java multithreaded programming.
    In order to understand more about threading mechanism, I would like to first know more about the processors,operating systems.
    Please let me know which book or web site to follow to get a brief but good idea about processors,operating systems that would eventually let me go further with the understanding of multithreading mechanism in java.
    Any input is highly appreciated.
    Thanks in advance.

    Multithread programming is a difficult topic.
    If you protect every access to shared memory by using synchronized methods, you are on the safe side.
    But things are not so simple in the real world.
    Sooner or later, you will face deadlock problems, for instance, and you will learn how to avoid them.
    With more experience, you will be tempted to use some "tricks" that you will find on the internet ( double-locking idiom or things like that ), not understanding why it is dangerous and does not work.
    If you continue your investigation, you will end up with concepts such as memory barrier, race conditions, spinlocks, mutexes, memory model, processor cache and SMP, instruction reordering, and more.
    ( google some of these topics how wide the landscape is )
    In fact, the more you work with it, the more you will have questions about it, and the more you will want to learn about it.
    I also thought that multithreading was easy, three years ago, but it is not true.
    Today, I continue to read books about it.
    Read a lot ! The topic is wide, but the more you know about it, the best you can use it and be confident with it !
    It is worth the effort, as multithreading is here to stay and seems to be everywhere.
    Multithreading is difficult to understand fully, but very interesting.
    Besides, if you write code for server programs ( serving multiple clients ), you must be aware of it.
    Eventually, you will perhaps read this book:
    UNIX(R) Systems for Modern Architectures: Symmetric Multiprocessing and Caching for Kernel Programmers
    by Curt Schimmel
    It is not about java, but if you want to really understand java, you must learn about the underlying layers, and even how a processor works.
    As an example of what not to do and that I saw in an introductory book about java, the following code is full of bugs and does not work !
    You cannot stop the looping thread B by just setting and testing a global flag like that.
    static int stopflag = 0;
    Thread A:
    public void stop_B_thread()
    stopflag = 1;
    Thread B:
    while (stopflag == 0)
    // do some job

  • Unicode programming on Solaris.

    Hi All,
    I am very new to Solarsi and working on unicode programming on Solaris. But I am unable to find very basic APIs like wcsdup(), wtoi(), wtof(), snwprintf(). I am working on Solaris 10 with gcc 3.4.6. Please suggest me what could be the reason or these APIs are not on Solaris or I have to upgarade the gcc version to work on unicode programming ? Any pointer in the direction would be helpfull.
    Thanks in advance.

    Set an alarm timer in the parent process. Waitid for the child to complete.
    - If the child completes, cancel the timer with alarm(0).
    - If the timer pops, issue a kill -15/9 to the child process, then waitid to clean up the zombie. You can check for EINTR returned from your waitid and kill the child then if you don't want to do it in the interrupt handler.
    Dave

  • How to send mail through java program in solaris server

    hi
    i am writing java code to send the mail using my company SMTP
    ,the program is working fine when i run and deploy in windows environment
    but at the same time when i deploy the war to sun solaris server ,it is not working
    and throwing the Error saying
    java.lang.Exception: Invalid Addresses; nested exception is:      javax.mail.SendFailedException: 553 sorry, that domain isn't allowed to be relayed thru this MTA without authentication #5.7.1     at jsp.SendMail._jspService(_SendMail.java:137)
    i am using the Authentication also using user id and password of same domain and it is able to authenticate
    in windows but not in Solaris
    where i am making mistake plz
    guide.
    Saurabh

    thanks Alan
    but i think there is some other problem because same code is
    working when i am using in windows as well as i am using authentication method
    also but it is not working when running in Solaris Environment
    here is the code i am using to send the mail
    props.setProperty("mail.transport.protocol", "smtp");
    props.setProperty("mail.host", "smtp.mycompany.com");//smtp protocol for IIBF
    props.put("mail.smtp.starttls.enable","true");//setting start TLS to be true
    props.put("mail.smtp.auth", "true");// authentication is false
    props.put("mail.smtp.port", port);//setting the port number it can be either 25 or 587
    props.put("mail.smtp.username", "noreply");
    props.put("mail.smtp.password","noreply");
    props.put("mail.debug", "true");
    Authenticator auth = new SMTPAuthenticator();
    Session session1 = Session.getDefaultInstance(props);
    java.util.Properties sessionProperties = new java.util.Properties();
    sessionProperties.put("mail.smtp.auth", "true");
    message.setFrom(new javax.mail.internet.InternetAddress(From ,"name"));
    message.addRecipient(javax.mail.Message.RecipientType.TO, new javax.mail.internet.InternetAddress(To));
    message.setText(TextCo);
    message.setSubject(subject);
    message.setContent(boyd, "text/plain");
    message.reply(true);
    Transport trans = session1.getTransport("smtp");
    trans.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
    boolean ddd = trans.isConnected();
    message.saveChanges();
    trans.sendMessage(message, message.getAllRecipients());
    above code is working properly in windows but not in Solaris
    plz guide what next to do
    thankx in advance
    saurabh

  • Signals in Multithreaded Application on Solaris 10.

    HI All,
    I need to know are the signal handlers are inherited by threads.
    Assume I have defined a signal handler (assume for SIGCHLD )in main function before the creation of threads, and after that I create 5 threads. Can anyone please tell me if the signal SIGCHLD comes to any of the 5 threads will it be handled as signal handler defined earlier.
    Any comments will be appreciated.
    Regards,
    Rahul.

    What do you mean by 'linux application'? Right now, you'd have to recompile the program from source on Solaris or install a precompiled Solaris package.
    After the release of project Janus, you might have some other choices to run Linux binaries directly on a Solaris (x86) machine.
    Darren

  • How to execute Java program in Solaris 8 (Intel Platform).

    Hello All,
    I have installed Solaris 8 on my Intel based PC. JDk 1.1 and JDK 1.2 is installed by default. When I compile any Java applet or Application, it successfull complies but when I try run that applet or application (java Appletname or applicationname), It gives the error message .... File not found...Check whether file exist in the directory or not.
    Can someone tell me the reason of this error and how to correct it. Where to set the CLASSPATh etc. under Solaris 8 for successful compilation and run of programs. I do not have any problem under Windows/2000.
    Thanks in advance,
    Amoid

    [amoyeed],
    Hello All,
    I have installed Solaris 8 on my Intel based PC. JDk
    1.1 and JDK 1.2 is installed by default. When I
    compile any Java applet or Application, it successfull
    compliesI will assume that you executed this command:
    #javac <java source code filename>.java
    In order to find out which version of the javac you are using to compile the program, execute the following:
    #/usr/bin/which javac
    The output will tell the exact path to the javac binary file.
    but when I try run that applet or application
    (java Appletname or applicationname), It gives the
    error message .... File not found...Check whether file
    exist in the directory or not.You probably have not set the current directory to your environment variable PATH for the Unix shell that you are using.
    You can do the following:
    #java ./<standalone application or applet name>
    Can someone tell me the reason of this error and how
    to correct it. Where to set the CLASSPATh etc. under
    Solaris 8 for successful compilation and run of
    programs.In the shell environment settings file. Which Unix shell are you using? Bourne, Korn or C?
    I do not have any problem under Windows/2000.
    Thanks in advance,
    AmoidHTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • How to Debug C++ Multithreaded Application in Solaris

    Hi All,
    I am working in Solaris Sparc 5.8 Machine. I need to debug Multithreaded C++ Application in Unix Environment.
    I am using dbx debugger.
    Please explain me how to debug multithreaded applications. if possible please explain me with example.
    Thanks in Advance.
    Thanks & Regards,
    Vasu

    1. Look over the dbx manual that comes with Sun Studio. Dbx includes many features for debugging MT code.
    2. If you have specific questions after reading the manual and trying out the features, ask them in the debugger forum:
    http://forum.sun.com/forum.jspa?forumID=257

  • Running Solaris9 built C++ program on Solaris 10

    Hello,
    I have an executable that builts and runs fine on Solaris 9. Once copied to a Solaris 10 machine, it is not recognized as an executable.
    On Solairs 9 machine:
    $ uname -a
    SunOS sunqas2 5.9 Generic_117171-07 sun4u sparc SUNW,Sun-Fire-280R
    $ file LX
    LX: ELF 64-bit MSB executable SPARCV9 Version 1, UltraSPARC3 Extensions Required, dynamically linked, stripped
    $ ldd LX
    libnsl.so.1 => /usr/lib/64/libnsl.so.1
    libsocket.so.1 => /usr/lib/64/libsocket.so.1
    libxerces-c.so.27 => /numetrix/SNO/donc/scp/12.1.3/common/bin_64/libxerces-c.so.27
    libQt3Support.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQt3Support.so.4
    libQtNetwork.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtNetwork.so.4
    libQtScript.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtScript.so.4
    libQtCore.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtCore.so.4
    libQtSql.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtSql.so.4
    libQtSvg.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtSvg.so.4
    libQtGui.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtGui.so.4
    libQtXml.so.4 => /numetrix/SNO/donc/scp/12.1.3/common/bin/libQtXml.so.4
    libdl.so.1 => /usr/lib/64/libdl.so.1
    libX11.so.4 => /usr/lib/64/libX11.so.4
    libXext.so.0 => /usr/lib/64/libXext.so.0
    libXt.so.4 => /usr/lib/64/libXt.so.4
    libCstd.so.1 => /usr/lib/64/libCstd.so.1
    libCrun.so.1 => /usr/lib/64/libCrun.so.1
    libm.so.1 => /usr/lib/64/libm.so.1
    libthread.so.1 => /usr/lib/64/libthread.so.1
    libc.so.1 => /usr/lib/64/libc.so.1
    libmp.so.2 => /usr/lib/64/libmp.so.2
    libpthread.so.1 => /lib/sparcv9/libpthread.so.1
    libSM.so.6 => /lib/sparcv9/libSM.so.6
    libICE.so.6 => /lib/sparcv9/libICE.so.6
    libXi.so.5 => /lib/sparcv9/libXi.so.5
    libresolv.so.2 => /lib/sparcv9/libresolv.so.2
    libxnet.so.1 => /lib/sparcv9/libxnet.so.1
    librt.so.1 => /lib/sparcv9/librt.so.1
    libaio.so.1 => /usr/lib/64/libaio.so.1
    libmd5.so.1 => /usr/lib/64/libmd5.so.1
    /usr/platform/SUNW,Sun-Fire-280R/lib/sparcv9/libc_psr.so.1
    /usr/platform/SUNW,Sun-Fire-280R/lib/sparcv9/libmd5_psr.so.1
    On Solaris 10 machine:
    $ uname -a
    SunOS sunlab4 5.10 Generic sun4u sparc SUNW,UltraAX-i2
    $ file LX
    LX: ELF 64-bit MSB executable SPARCV9 Version 1, UltraSPARC3 Extensions Required, dynamically linked, stripped
    $ ls -l
    total 48626
    -rwxrwxrwx 1 snouser1 snogrp 19891448 May 27 02:25 LX
    $ ./LX
    ksh: ./LX: cannot execute
    $ ldd ./LX
    ldd: ./LX: execution failed ./LX: Invalid argument
    Is this due to the above string "UltraSPARC3 extension required"?
    To make it more interesting, another C++ executable built under the same Solaris 9 env runs fine on Solaris 10. It profile does not have this string.
    $ file DISP
    DISP: ELF 64-bit MSB executable SPARCV9 Version 1, dynamically linked, stripped
    Thanks a lot for your help!
    DC

    So far I tried the following option sets:
    1. Compile: '-mt -xarch=v9 -xchip=ultra3 -features=rtti -features=localfor -xO3
    Link: -xarch=v9 -norunpath -xchip=ultra3 -s
    2. Compile: '-mt -xarch=v9 -features=rtti -features=localfor -xO3
    Link: -xarch=v9 -norunpath -s
    3. Compile: '-mt -xarch=v9 -features=rtti -features=localfor -xO
    Link: -xarch=v9 -norunpath -s
    4. Compile: '-mt -xarch=generic64 -features=rtti -features=localfor -xO
    Link: -xarch=generic64 -norunpath -s
    None works for me.
    What adds confusion is I have another program that uses the exact same option sets and shared libraries. And it works on my target machine. The only difference I can tell is it does not have "ultraSPARC3 extension required". How can I find what needs the extensions?

Maybe you are looking for

  • Selecting multiple rows in a table

    Hi All, I have one problem with selecting multiple rows in a table.I tried with setting table property-selectionMode as Multi, but i dinn't get the solution. please provide me solution for this. Thanks & Regards, Sreelakshmi.

  • How to display an html located in server to client browser?

    Hi, i want to display an html file located at the server to a client browser. how can i do it? and i want the user to select the particular file thru an open dialog box. will it be possible? regds, Abhi...

  • Creating Oracle Obj Model hangs - SQLServer 2000 to Oracle9i

    Migration Workbench process appears to hang during "Mapping Priomary Keys" while creating Oracle Object Model. I am migrating SQLServer 2000 database to Oracle 9i. All on one single PC using Windows 2000 server. I downloaded latest SQLServer 2000 plu

  • Enabling Suite Color Management on Bridge

    When I go into Edit >>>Creative Suite Color Settings   I receive an error window informing me that it hasn't been enabled and at least one qualifying product needs to be launched at least once to enable Suite Color Management. I have opened Illustrat

  • Manipulation of LongRaw objects.

    Hi all! I have an application in which I am using OLE Container item to embed employees photographs into the Oracle table. The field is defined as a LONG RAW. I wanted to fetch the photograph of the employee based on the employee number entered by th