> I don't get what you want to do here.

I wan't to get rid of the backspace that SGE is printing.

Here's something I came up with, as a proof of concept for
getting rid of the backspace, which relies on the fact that
printf doesn't care if it had more arguments than it does
placeholders in the format string.

You thus simply write the word INFINITY out where you need
it and stick in the platform specific int placeholder
elsewhere.

Note that this PoC explicity sets the resource to query

 RLIMIT_DATA

and sets the "max" of that,

 dlp.rlim_max

to the "infinity value" for testing.

---8<------------8<------------8<------------8<---------
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>

#if defined(DARWIN) || defined(FREEBSD) || defined(NETBSD)
#   include <sys/time.h>
#endif

#if defined(CRAY)
#   include <sys/param.h>
#   include <sys/unistd.h>
#   include <sys/category.h>
#endif

#include <sys/resource.h>

#if defined(IRIX)
#   define RLIMIT_STRUCT_TAG rlimit64
#   define RLIMIT_INFINITY RLIM64_INFINITY
#else
#   define RLIMIT_STRUCT_TAG rlimit
#   define RLIMIT_INFINITY RLIM_INFINITY
#endif

/* Format the value, if val == INFINITY, print 0 as it will be binned */
#define FORMAT_LIMIT(x) (x==RLIMIT_INFINITY)?0:x

int main( void ) {

  int resource = RLIMIT_DATA ;

  char trace_str[1024];

#if defined(NECSX4) || defined(NECSX5) || defined(NETBSD_ALPHA) ||
defined(NETBSD_X86_64) || defined(NETBSD_SPARC64)
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"INFINITY":"%ld"
#elif defined(IRIX) || defined(HPUX) || defined(DARWIN) ||
defined(FREEBSD) || defined(NETBSD) || defined(INTERIX)
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"INFINITY":"%lld"
#elif (defined(LINUX) && defined(TARGET_32BIT))
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"INFINITY":"%llu"
#elif defined(ALPHA) || defined(SOLARIS) || defined(LINUX)
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"INFINITY":"%lu"
#else
#  define FORMAT_LIMIT_STR(x) (x==RLIMIT_INFINITY)?"INFINITY":"%d"
#endif


  struct RLIMIT_STRUCT_TAG dlp;

#if defined(IRIX)
  getrlimit64(resource,&dlp);
#else
  getrlimit(resource,&dlp);
#endif

  dlp.rlim_max = RLIMIT_INFINITY ;

  sprintf(trace_str, "soft %s, hard %s\n",
         FORMAT_LIMIT_STR(dlp.rlim_cur),
         FORMAT_LIMIT_STR(dlp.rlim_max) );

  /*  printf( "%s\n", trace_str );
   */

  printf( trace_str,
         FORMAT_LIMIT(dlp.rlim_cur),
         FORMAT_LIMIT(dlp.rlim_max) );

  return(0);

}
---8<------------8<------------8<------------8<---------



-- 
Kevin M. Buckley                                  Room:  CO327
School of Engineering and                         Phone: +64 4 463 5971
 Computer Science
Victoria University of Wellington
New Zealand

_______________________________________________
users mailing list
[email protected]
https://gridengine.org/mailman/listinfo/users

Reply via email to