Sponsored Content
Top Forums Programming warning: int format,pid_t arg (arg 2) Post 302329698 by mgessner on Monday 29th of June 2009 08:39:43 AM
Old 06-29-2009
Because pid's differ widely across systems, the only thing you can really do (aside from changing printf() and adding a new class of object) is to cast intelligently:

Code:
printf ("pid = %lu\n", (unsigned long) getpid());

It's a reasonable assumption that a PID is an unsigned integer type.

HTH. YMMV.
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

arg list too long

I do ls -l ABC*, I get arg list too long message. This will not happen if ABC* has small no of files I believe 4000 files is limit. Any way of avoiding this. I even tried like this for i in `ls -l ABC*` do echo $i done Same problem. Any solution would be great. I am on HP-UX... (5 Replies)
Discussion started by: vingupta
5 Replies

2. UNIX for Advanced & Expert Users

arg list too long

Does anyone have a solution for arg list too long error. I have got this from the web but I fail to make any sense out of it Thanks enc (8 Replies)
Discussion started by: encrypted
8 Replies

3. UNIX for Dummies Questions & Answers

ls -t arg list too long

echo dirname/filename* | xargs ls -t As a substitute doesn't give the results desired when I exceed the buffer size. I still want the files listed in chronological order, unfortunately xargs releases the names piecemeal...does anyone have any ideas? :( (4 Replies)
Discussion started by: CSU_Ram
4 Replies

4. Shell Programming and Scripting

arg list too long

Hi, Help. I have a file that contains a list of users in a file. I want to cat the content of the file and feed it into sed to a preformated report. The error I got is "ksh: /usr/bin/sed: arg list too long" My method below. A=`cat FILE1.txt` B=`echo $A` sed "s#USERLIST#$B#" FILE2 >... (2 Replies)
Discussion started by: Zenwork
2 Replies

5. UNIX for Dummies Questions & Answers

Space in a arg

Hi, When i am running a script it considers the below as mulitple arguments. There is any command which can ignore the spaces. I tried by using sed like below to ignore but it doesnt work. sed 's/ /\\ /g'100% Haddock Fillets Battered 500G-small.gif ~vino (3 Replies)
Discussion started by: vino_hymi
3 Replies

6. Programming

warning: passing arg 1 of `inet_addr' makes pointer from integer without a cast

I use solaris10,following is tcp client code: #include "cliserv.h" int main(int argc,char argv){ struct sockaddr_in serv; char request,reply; int sockfd,n; if(argc!=2) err_quit("usage: tcpclient <IP address of server>"); if((sockfd=socket(PF_INET,SOCK_STREAM,0))<0) ... (1 Reply)
Discussion started by: konvalo
1 Replies

7. Shell Programming and Scripting

Copy from/to file, if arg 'ok'

Hello, I've just started with shell scripting, and I need som assistance! Basicly what I want to do is copy names from one file to another, when running the scrip the user should be asked about the status of these names. Let me demonstrate: file: Name: John, Gender: male Name: Jane,... (6 Replies)
Discussion started by: klskl
6 Replies

8. Shell Programming and Scripting

Bash script too many arg's

I have a simple bash script on RHEL that works fine when there is one file but when it finds multiple files of same condition I get too many args error. for i in * do if ;then echo "no files to move" exit 0 fi if ; then ... (10 Replies)
Discussion started by: jcalisi
10 Replies

9. Shell Programming and Scripting

Execute arg with ssh

Hello, I am trying to execute remote script with ssh : ssh -o ConnectTimeout=10 -o PasswordAuthentication=no -o NumberOfPasswordPrompts=0 -o StrictHostKeyChecking=no root@host '/arbo/script -t' My script is well executed, but my option '-t' is never loaded, how can you explain that ? (2 Replies)
Discussion started by: cterra
2 Replies
pctx_set_events(3CPC)				    CPU Performance Counters Library Functions				     pctx_set_events(3CPC)

NAME
pctx_set_events - associate callbacks with process events SYNOPSIS
cc [ flag... ] file... -lpctx [ library... ] #include <libpctx.h> typedef enum { PCTX_NULL_EVENT = 0, PCTX_SYSC_EXEC_EVENT, PCTX_SYSC_FORK_EVENT, PCTX_SYSC_EXIT_EVENT, PCTX_SYSC_LWP_CREATE_EVENT, PCTX_INIT_LWP_EVENT, PCTX_FINI_LWP_EVENT, PCTX_SYSC_LWP_EXIT_EVENT } pctx_event_t; typedef int pctx_sysc_execfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, char *cmd, void *arg); typedef void pctx_sysc_forkfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, pid_t child, void *arg); typedef void pctx_sysc_exitfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg); typedef int pctx_sysc_lwp_createfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg); typedef int pctx_init_lwpfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg); typedef int pctx_fini_lwpfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg); typedef int pctx_sysc_lwp_exitfn_t(pctx_t *pctx, pid_t pid, id_t lwpid, void *arg); int pctx_set_events(pctx_t *pctx, ...); DESCRIPTION
The pctx_set_events() function allows the caller (the controlling process) to express interest in various events in the controlled process. See pctx_capture(3CPC) for information about how the controlling process is able to create, capture and manipulate the controlled process. The pctx_set_events() function takes a pctx_t handle, followed by a variable length list of pairs of pctx_event_t tags and their corre- sponding handlers, terminated by a PCTX_NULL_EVENT tag. Most of the events correspond closely to various classes of system calls, though two additional pseudo-events (init_lwp and fini_lwp) are provided to allow callers to perform various housekeeping tasks. The init_lwp handler is called as soon as the library identifies a new LWP, while fini_lwp is called just before the LWP disappears. Thus the classic "hello world" program would see an init_lwp event, a fini_lwp event and (process) exit event, in that order. The table below displays the interactions between the states of the controlled process and the handlers executed by users of the library. +-----------------------------------------------------------------------+ | System Calls and pctx Handlers | +-------------------+--------------+------------------------------------+ |System call | Handler |Comments | +-------------------+--------------+------------------------------------+ |exec, execve | fini_lwp |Invoked serially on all lwps in the | | | |process. | +-------------------+--------------+------------------------------------+ | | exec |Only invoked if the exec() system | | | |call succeeded. | +-------------------+--------------+------------------------------------+ | | init_lwp |If the exec succeeds, only invoked | | | |on lwp 1. If the exec fails, | | | |invoked serially on all lwps in the | | | |process. | +-------------------+--------------+------------------------------------+ |fork, vfork, fork1 | fork |Only invoked if the fork() system | | | |call succeeded. | +-------------------+--------------+------------------------------------+ |exit | fini_lwp |Invoked on all lwps in the process. | +-------------------+--------------+------------------------------------+ | | exit |Invoked on the exiting lwp. | +-------------------+--------------+------------------------------------+ Each of the handlers is passed the caller's opaque handle, a pctx_t handle, the pid, and lwpid of the process and lwp generating the event. The lwp_exit, and (process) exit events are delivered before the underlying system calls begin, while the exec, fork, and lwp_create events are only delivered after the relevant system calls complete successfully. The exec handler is passed a string that describes the command being executed. Catching the fork event causes the calling process to fork(2), then capture the child of the controlled process using pctx_capture() before handing control to the fork handler. The process is released on return from the handler. RETURN VALUES
Upon successful completiion, pctx_set_events() returns 0. Otherwise, the function returns -1. EXAMPLES
Example 1: HandleExec example. This example captures an existing process whose process identifier is pid, and arranges to call the HandleExec routine when the process performs an exec(2). static void HandleExec(pctx_t *pctx, pid_t pid, id_t lwpid, char *cmd, void *arg) { (void) printf("pid %d execed '%s' ", (int)pid, cmd); } int main() { ... pctx = pctx_capture(pid, NULL, 1, NULL); (void) pctx_set_events(pctx, PCTX_SYSC_EXEC_EVENT, HandleExec, ... PCTX_NULL_EVENT); (void) pctx_run(pctx, 0, 0, NULL); pctx_release(pctx); } ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Evolving | +-----------------------------+-----------------------------+ |MT-Level |Unsafe | +-----------------------------+-----------------------------+ SEE ALSO
exec(2), exit(2), fork(2), vfork(2), fork1(2), cpc(3CPC), libpctx(3LIB), proc(4), attributes(5) SunOS 5.10 13 May 2003 pctx_set_events(3CPC)
All times are GMT -4. The time now is 10:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy