Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Trigger execution of commands whenever number of file descriptors changes Post 302363090 by jim mcnamara on Monday 19th of October 2009 10:56:49 AM
Old 10-19-2009
Solaris does not have inotify - a popen() call to fuser can do that for you. The best choice is to use the /proc directory via pfiles [pid]:
something like this --
Code:
#include <unistd.h>
#include <stdio.h>
#include <limits.h>
#include <stdlib.h>

int openfilecnt(void)
{
    int retval=0;
    FILE *cmd=NULL;
    char tmp[256]={0x0};
    char cmdstr[PATH_MAX+1]={0x0};
    sprintf(cmdstr, "/usr/bin/pfiles %d", getpid() );
    cmd=popen(cmdstr, "r");
    if(cmd==NULL) 
       { perror("command error"); exit(1);}
    while (fgets(tmp, sizeof(tmp), cmd)!=NULL)
    {
       retval++;
    }
    pclose(cmd);
    return (retval -2)/2;  
}

Next time. mention your OS, it helps a lot.
 

10 More Discussions You Might Find Interesting

1. Programming

File Descriptors

Hi, I have written a daemon process, to perform certain operations in the background. For this I have to close, the open file descriptors, Does anybody know how to find out the number of open file descriptors ? Thanks in Advance, Sheetal (2 Replies)
Discussion started by: s_chordia
2 Replies

2. UNIX for Advanced & Expert Users

File Descriptors

Hello all, A few questions on file descriptors ... scenario : Sun Ultra 30 with Sun OS 5.5.1 , E250 with Solaris 2.6 In one of my servers, the file descriptor status from the soft limit and hard limits are 64 and 1024 respectively for root user. Is the soft limit (64) represents the... (3 Replies)
Discussion started by: shibz
3 Replies

3. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (0 Replies)
Discussion started by: ran16
0 Replies

4. Shell Programming and Scripting

Problem while execution of second set of commands

Hi, I have a shell script with code . perf.env cd $QRY_DIR for SHELL_FILE in sql1 do export SNAME=$SHELL_FILE ${SCRIPT_DIR}/perf_qry.sh ${SPOOL_DIR} ${DB_ENVNAME} ${NAME} & RC=$(expr ${RC:-0} + $? ) sleep 60 if then echo sysdate>test1 echo query1.txt>>test1 grep -i... (6 Replies)
Discussion started by: ran16
6 Replies

5. UNIX for Advanced & Expert Users

multiple commands execution

Hi i have 3 sql scripts that need to be executed simultaneously, and independent of one another, how do i do that in Unix AIX 5.3 (1 Reply)
Discussion started by: yschd
1 Replies

6. Shell Programming and Scripting

Sequential execution of commands in ksh

I need to run few commands in a ksh script sequentially. Some of the commands are jobs submitted to the server and the consecutive commands are dependent on the completion of the jobs submitted to the server. It works if i separate the commands into different files like this #!/bin/ksh... (1 Reply)
Discussion started by: prashob123
1 Replies

7. Shell Programming and Scripting

Execution of Shell Commands

I have a question: Where would I put the Command line (of any command) so that it executes every time I log on? Where would I put it if I want it to execute every time I start a new shell? (5 Replies)
Discussion started by: Nabeel Nazir
5 Replies

8. Shell Programming and Scripting

Perl execution commands

I don't know to debug the program todaylive.pl program. plz someone let me know what are the commands I need to know to debug the perl programs to find out the error on it. (3 Replies)
Discussion started by: ramkumar15
3 Replies

9. Shell Programming and Scripting

Trigger the execution of a script on SFTP Disconnect

Hi Guys, I suspect what I'm trying to do isn't possible, but I'm hoping someone can either confirm this or point me in the right direction. We have a third-party application which transfers a collection of files to our SFTP server ( Ubuntu 12.04 with OpenSSH ) . Once the app disconnects, we... (13 Replies)
Discussion started by: jamesdrinkwater
13 Replies

10. Shell Programming and Scripting

Linux Commands needed for replacing variable number of spaces with a single , in a txt file

Hi I want to read a text file and replace various number of spaces between each string in to a single "," or any other character .Please let me know the command to do so. My input file is a txt file which is the output of a SQL table extract so it contains so many spaces between each column of the... (2 Replies)
Discussion started by: Hari Prasanth
2 Replies
PAPI_library_init(3)						       PAPI						      PAPI_library_init(3)

NAME
PAPI_library_init - initialize the PAPI library. SYNOPSIS
Detailed Description @param version upon initialization, PAPI checks the argument against the internal value of PAPI_VER_CURRENT when the library was compiled. This guards against portability problems when updating the PAPI shared libraries on your system. @retval PAPI_EINVAL papi.h is different from the version used to compile the PAPI library. @retval PAPI_ENOMEM Insufficient memory to complete the operation. @retval PAPI_ECMP This component does not support the underlying hardware. @retval PAPI_ESYS A system or C library call failed inside PAPI, see the errno variable. PAPI_library_init() initializes the PAPI library. PAPI_is_initialized() check for initialization. It must be called before any low level PAPI functions can be used. If your application is making use of threads PAPI_thread_init must also be called prior to making any calls to the library other than PAPI_library_init() . @par Examples: * int retval; * retval = PAPI_library_init(PAPI_VER_CURRENT); * if (retval != PAPI_VER_CURRENT && retval > 0) { * fprintf(stderr,"PAPI library version mismatch! "); * exit(1); } * if (retval < 0) * handle_error(retval); * retval = PAPI_is_initialized(); * if (retval != PAPI_LOW_LEVEL_INITED) * handle_error(retval) * See Also: PAPI_thread_init PAPI Author Generated automatically by Doxygen for PAPI from the source code. Version 5.2.0.0 Tue Jun 17 2014 PAPI_library_init(3)
All times are GMT -4. The time now is 06:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy