我在xv6中进行了系统调用,并尝试更改进程名称。进程名称存在于下面显示的proc结构中:
// Per-process state
struct proc {
uint sz; // Size of process memory (bytes)
pde_t* pgdir; // Page table
char *kstack; // Bottom of kernel stack for this process
enum procstate state; // Process state
volatile int pid; // Process ID
struct proc *parent; // Parent process
struct trapframe *tf; // Trap frame for current syscall
struct context *context; // swtch() here to run process
void *chan; // If non-zero, sleeping on chan
int killed; // If non-zero, have been killed
struct file *ofile[NOFILE]; // Open files
struct inode *cwd; // Current directory
char name[16]; // Process name (debugging)
};
我尝试使用以下代码访问该名称,并为其指定一个值:
void modifyCurrentProcessName(char* newName)
{
proc->name= &newName;
}
我收到以下错误:
proc.c:在函数'modifyCurrentProcessName'中:proc.c:490:15:错误: 赋值给数组类型的表达式 proc-> name =& newName; ^:目标'proc.o'的配方失败make:*** [proc.o]错误1