Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1019151
  • 博文数量: 326
  • 博客积分: 10135
  • 博客等级: 上将
  • 技术积分: 2490
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-22 23:53
文章分类

全部博文(326)

文章存档

2014年(1)

2012年(4)

2011年(1)

2010年(4)

2009年(41)

2008年(44)

2007年(63)

2006年(168)

我的朋友

分类: LINUX

2009-11-24 16:33:06

/* proctitle code - we know this to work only on linux... */

/*
** SETPROCTITLE -- set process title for ps (from sendmail)
**
** Parameters:
** fmt -- a printf style format string.
**
** Returns:
** none.
**
** Side Effects:
** Clobbers argv of our main procedure so ps(1) will
** display the title.
*/


# <.>
# <.>
# <.>
# <.>
# "setproctitle.h"

#
# 2048
#

extern char** ;

static char** ;
static int ;

void
(int , char **) {
int ;
char ** = ;

/*
* Move the environment so we can reuse the memory.
* (Code borrowed from sendmail.)
* WARNING: ugly assumptions on memory layout here;
* if this ever causes problems, #undef DO_PS_FIDDLING
*/

for ( = 0; [] != ; ++)
continue;
= (char **) (sizeof(char *) * ( + 1));
if ( == )
return;
for ( = 0; [] != ; ++)
if (([] = ([])) == )
return;
[] = ;

= ;
if ( > 0)
= [-1] + ([-1]) - [0];
else
= [-1] + ([-1]) - [0];
}

#if 0
/* Nice code, but many places do not know about vsnprintf ... */
void
(const char *,...) {
int ;
char [];
;

if (!)
return;

(, );
(void) (, , , );
();

= ();
if ( > - 2) {
= - 2;
[] = '\0';
}
([0], '\0', ); /* clear the memory area */
(void) ([0], );

[1] = ;
}
#else
void
(const char *, const char *) {
int ;
char [];

if (!)
return;

if (() + () + 5 > )
return;

(void) (, "%s -- %s", , );

= ();
if ( > - 2) {
= - 2;
[] = '\0';
}
([0], '\0', ); /* clear the memory area */
(void) ([0], );

[1] = ;
}
#
阅读(940) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~